oracle.oci.oci_network_load_balancer – Manage a NetworkLoadBalancer resource in Oracle Cloud Infrastructure

Note

This plugin is part of the oracle.oci collection (version 4.10.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install oracle.oci.

To use it in a playbook, specify: oracle.oci.oci_network_load_balancer.

New in version 2.9.0: of oracle.oci

Synopsis

  • This module allows the user to create, update and delete a NetworkLoadBalancer resource in Oracle Cloud Infrastructure

  • For state=present, creates a network load balancer.

  • This resource has the following action operations in the oracle.oci.oci_network_load_balancer_actions module: change_compartment.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter Choices/Defaults Comments
api_user
string
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_ID environment variable, if any, is used. This option is required if the user is not specified through a configuration file (See config_file_location). To get the user's OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_fingerprint
string
Fingerprint for the key pair being used. If not set, then the value of the OCI_USER_FINGERPRINT environment variable, if any, is used. This option is required if the key fingerprint is not specified through a configuration file (See config_file_location). To get the key pair's fingerprint value please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_key_file
string
Full path and filename of the private key (in PEM format). If not set, then the value of the OCI_USER_KEY_FILE variable, if any, is used. This option is required if the private key is not specified through a configuration file (See config_file_location). If the key is encrypted with a pass-phrase, the api_user_key_pass_phrase option must also be provided.
api_user_key_pass_phrase
string
Passphrase used by the key referenced in api_user_key_file, if it is encrypted. If not set, then the value of the OCI_USER_KEY_PASS_PHRASE variable, if any, is used. This option is required if the key passphrase is not specified through a configuration file (See config_file_location).
auth_purpose
string
    Choices:
  • service_principal
The auth purpose which can be used in conjunction with 'auth_type=instance_principal'. The default auth_purpose for instance_principal is None.
auth_type
string
    Choices:
  • api_key ←
  • instance_principal
  • instance_obo_user
  • resource_principal
The type of authentication to use for making API requests. By default auth_type="api_key" based authentication is performed and the API key (see api_user_key_file) in your config file will be used. If this 'auth_type' module option is not specified, the value of the OCI_ANSIBLE_AUTH_TYPE, if any, is used. Use auth_type="instance_principal" to use instance principal based authentication when running ansible playbooks within an OCI compute instance.
cert_bundle
string
The full path to a CA certificate bundle to be used for SSL verification. This will override the default CA certificate bundle. If not set, then the value of the OCI_ANSIBLE_CERT_BUNDLE variable, if any, is used.
compartment_id
string
The OCID of the compartment containing the network load balancer.
Required for create using state=present.
Required for update when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
Required for delete when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
config_file_location
string
Path to configuration file. If not set then the value of the OCI_CONFIG_FILE environment variable, if any, is used. Otherwise, defaults to ~/.oci/config.
config_profile_name
string
The profile to load from the config file referenced by config_file_location. If not set, then the value of the OCI_CONFIG_PROFILE environment variable, if any, is used. Otherwise, defaults to the "DEFAULT" profile in config_file_location.
defined_tags
dictionary
Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace": {"bar-key": "value"}}`
This parameter is updatable.
display_name
string
Network load balancer identifier, which can be renamed.
Required for create using state=present.
Required for update, delete when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
This parameter is updatable when OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: name
force_create
boolean
    Choices:
  • no ←
  • yes
Whether to attempt non-idempotent creation of a resource. By default, create resource is an idempotent operation, and doesn't create the resource if it already exists. Setting this option to true, forcefully creates a copy of the resource, even if it already exists.This option is mutually exclusive with key_by.
freeform_tags
dictionary
Simple key-value pair that is applied without any predefined name, type, or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
This parameter is updatable.
is_preserve_source_destination
boolean
    Choices:
  • no
  • yes
This parameter can be enabled only if backends are compute OCIDs. When enabled, the skipSourceDestinationCheck parameter is automatically enabled on the load balancer VNIC, and packets are sent to the backend with the entire IP header intact.
This parameter is updatable.
is_private
boolean
    Choices:
  • no
  • yes
Whether the network load balancer has a virtual cloud network-local (private) IP address.
If "true", then the service assigns a private IP address to the network load balancer.
If "false", then the service assigns a public IP address to the network load balancer.
A public network load balancer is accessible from the internet, depending on the security list rules for your virtual cloud network. For more information about public and private network load balancers, see How Network Load Balancing Works. This value is true by default.
Example: `true`
key_by
list / elements=string
The list of attributes of this resource which should be used to uniquely identify an instance of the resource. By default, all the attributes of a resource are used to uniquely identify a resource.
network_load_balancer_id
string
The OCID of the network load balancer to update.
Required for update using state=present when environment variable OCI_USE_NAME_AS_IDENTIFIER is not set.
Required for delete using state=absent when environment variable OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: id
nlb_ip_version
string
    Choices:
  • IPV4
  • IPV4_AND_IPV6
IP version associated with the NLB.
This parameter is updatable.
region
string
The Oracle Cloud Infrastructure region to use for all OCI API requests. If not set, then the value of the OCI_REGION variable, if any, is used. This option is required if the region is not specified through a configuration file (See config_file_location). Please refer to https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm for more information on OCI regions.
reserved_ips
list / elements=dictionary
An array of reserved Ips.
id
string
OCID of the reserved public IP address created with the virtual cloud network.
Reserved public IP addresses are IP addresses that are registered using the virtual cloud network API.
Create a reserved public IP address. When you create the network load balancer, enter the OCID of the reserved public IP address in the reservedIp field to attach the IP address to the network load balancer. This task configures the network load balancer to listen to traffic on this IP address.
Reserved public IP addresses are not deleted when the network load balancer is deleted. The IP addresses become unattached from the network load balancer.
Example: "ocid1.publicip.oc1.phx.unique_ID"
state
string
    Choices:
  • present ←
  • absent
The state of the NetworkLoadBalancer.
Use state=present to create or update a NetworkLoadBalancer.
Use state=absent to delete a NetworkLoadBalancer.
subnet_id
string
The subnet in which the network load balancer is spawned OCIDs.
Required for create using state=present.
tenancy
string
OCID of your tenancy. If not set, then the value of the OCI_TENANCY variable, if any, is used. This option is required if the tenancy OCID is not specified through a configuration file (See config_file_location). To get the tenancy OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm
wait
boolean
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout
integer
Time, in seconds, to wait when wait=yes. Defaults to 1200 for most of the services but some services might have a longer wait timeout.

Examples

- name: Create network_load_balancer
  oci_network_load_balancer:
    # required
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    subnet_id: "ocid1.subnet.oc1..xxxxxxEXAMPLExxxxxx"
    display_name: display_name_example

    # optional
    reserved_ips:
    - # optional
      id: "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx"
    is_private: true
    is_preserve_source_destination: true
    nlb_ip_version: IPV4
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Update network_load_balancer
  oci_network_load_balancer:
    # required
    network_load_balancer_id: "ocid1.networkloadbalancer.oc1..xxxxxxEXAMPLExxxxxx"

    # optional
    display_name: display_name_example
    is_preserve_source_destination: true
    nlb_ip_version: IPV4
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Update network_load_balancer using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set)
  oci_network_load_balancer:
    # required
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    display_name: display_name_example

    # optional
    is_preserve_source_destination: true
    nlb_ip_version: IPV4
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Delete network_load_balancer
  oci_network_load_balancer:
    # required
    network_load_balancer_id: "ocid1.networkloadbalancer.oc1..xxxxxxEXAMPLExxxxxx"
    state: absent

- name: Delete network_load_balancer using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set)
  oci_network_load_balancer:
    # required
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    display_name: display_name_example
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
network_load_balancer
complex
on success
Details of the NetworkLoadBalancer resource acted upon by the current operation

Sample:
{'backend_sets': {'backends': [{'ip_address': 'ip_address_example', 'is_backup': True, 'is_drain': True, 'is_offline': True, 'name': 'name_example', 'port': 56, 'target_id': 'ocid1.target.oc1..xxxxxxEXAMPLExxxxxx', 'weight': 56}], 'health_checker': {'interval_in_millis': 56, 'port': 56, 'protocol': 'HTTP', 'request_data': None, 'response_body_regex': 'response_body_regex_example', 'response_data': None, 'retries': 56, 'return_code': 56, 'timeout_in_millis': 56, 'url_path': 'url_path_example'}, 'ip_version': 'IPV4', 'is_preserve_source': True, 'name': 'name_example', 'policy': 'TWO_TUPLE'}, 'compartment_id': 'ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx', 'defined_tags': {'Operations': {'CostCenter': 'US'}}, 'display_name': 'display_name_example', 'freeform_tags': {'Department': 'Finance'}, 'id': 'ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx', 'ip_addresses': [{'ip_address': 'ip_address_example', 'ip_version': 'IPV4', 'is_public': True, 'reserved_ip': {'id': 'ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx'}}], 'is_preserve_source_destination': True, 'is_private': True, 'lifecycle_details': 'lifecycle_details_example', 'lifecycle_state': 'CREATING', 'listeners': {'default_backend_set_name': 'default_backend_set_name_example', 'ip_version': 'IPV4', 'name': 'name_example', 'port': 56, 'protocol': 'ANY'}, 'network_security_group_ids': [], 'nlb_ip_version': 'IPV4', 'subnet_id': 'ocid1.subnet.oc1..xxxxxxEXAMPLExxxxxx', 'system_tags': {}, 'time_created': '2013-10-20T19:20:30+01:00', 'time_updated': '2013-10-20T19:20:30+01:00'}
 
backend_sets
complex
on success
Backend sets associated with the network load balancer.

   
backends
complex
on success
Array of backends.

     
ip_address
string
on success
The IP address of the backend server. Example: `10.0.0.3`

Sample:
ip_address_example
     
is_backup
boolean
on success
Whether the network load balancer should treat this server as a backup unit. If `true`, then the network load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "isBackup" fail the health check policy.
Example: `false`

Sample:
True
     
is_drain
boolean
on success
Whether the network load balancer should drain this server. Servers marked "isDrain" receive no incoming traffic.
Example: `false`

Sample:
True
     
is_offline
boolean
on success
Whether the network load balancer should treat this server as offline. Offline servers receive no incoming traffic.
Example: `false`

Sample:
True
     
name
string
on success
A read-only field showing the IP address/IP OCID and port that uniquely identify this backend server in the backend set.
Example: `10.0.0.3:8080`, or `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>:443` or `10.0.0.3:0`

Sample:
name_example
     
port
integer
on success
The communication port for the backend server.
Example: `8080`

Sample:
56
     
target_id
string
on success
The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`

Sample:
ocid1.target.oc1..xxxxxxEXAMPLExxxxxx
     
weight
integer
on success
The network load balancing policy weight assigned to the server. Backend servers with a higher weight receive a larger proportion of incoming traffic. For example, a server weighted '3' receives three times the number of new connections as a server weighted '1'. For more information about load balancing policies, see How Network Load Balancing Policies Work.
Example: `3`

Sample:
56
   
health_checker
complex
on success

     
interval_in_millis
integer
on success
The interval between health checks, in milliseconds. The default value is 10000 (10 seconds).
Example: `10000`

Sample:
56
     
port
integer
on success
The backend server port against which to run the health check. If the port is not specified, then the network load balancer uses the port information from the `Backend` object. The port must be specified if the backend port is 0.
Example: `8080`

Sample:
56
     
protocol
string
on success
The protocol the health check must use; either HTTP or HTTPS, or UDP or TCP.
Example: `HTTP`

Sample:
HTTP
     
request_data
string
on success
Base64 encoded pattern to be sent as UDP or TCP health check probe.

Sample:
null
     
response_body_regex
string
on success
A regular expression for parsing the response body from the backend server.
Example: `^((?!false).|\s)*$`

Sample:
response_body_regex_example
     
response_data
string
on success
Base64 encoded pattern to be validated as UDP or TCP health check probe response.

Sample:
null
     
retries
integer
on success
The number of retries to attempt before a backend server is considered "unhealthy". This number also applies when recovering a server to the "healthy" state. The default value is 3.
Example: `3`

Sample:
56
     
return_code
integer
on success
The status code a healthy backend server should return. If you configure the health check policy to use the HTTP protocol, then you can use common HTTP status codes such as "200".
Example: `200`

Sample:
56
     
timeout_in_millis
integer
on success
The maximum time, in milliseconds, to wait for a reply to a health check. A health check is successful only if a reply returns within this timeout period. The default value is 3000 (3 seconds).
Example: `3000`

Sample:
56
     
url_path
string
on success
The path against which to run the health check.
Example: `/healthcheck`

Sample:
url_path_example
   
ip_version
string
on success
IP version associated with the backend set.

Sample:
IPV4
   
is_preserve_source
boolean
on success
If this parameter is enabled, then the network load balancer preserves the source IP of the packet when it is forwarded to backends. Backends see the original source IP. If the isPreserveSourceDestination parameter is enabled for the network load balancer resource, then this parameter cannot be disabled. The value is true by default.

Sample:
True
   
name
string
on success
A user-friendly name for the backend set that must be unique and cannot be changed.
Valid backend set names include only alphanumeric characters, dashes, and underscores. Backend set names cannot contain spaces. Avoid entering confidential information.
Example: `example_backend_set`

Sample:
name_example
   
policy
string
on success
The network load balancer policy for the backend set.
Example: `FIVE_TUPLE`

Sample:
TWO_TUPLE
 
compartment_id
string
on success
The OCID of the compartment containing the network load balancer.

Sample:
ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx
 
defined_tags
dictionary
on success
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags.
Example: `{"Operations": {"CostCenter": "42"}}`

Sample:
{'Operations': {'CostCenter': 'US'}}
 
display_name
string
on success
A user-friendly name, which does not have to be unique, and can be changed.
Example: `example_load_balancer`

Sample:
display_name_example
 
freeform_tags
dictionary
on success
Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags.
Example: `{"Department": "Finance"}`

Sample:
{'Department': 'Finance'}
 
id
string
on success
The OCID of the network load balancer.

Sample:
ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
 
ip_addresses
complex
on success
An array of IP addresses.

   
ip_address
string
on success
An IP address.
Example: `192.168.0.3`

Sample:
ip_address_example
   
ip_version
string
on success
IP version associated with this IP address.

Sample:
IPV4
   
is_public
boolean
on success
Whether the IP address is public or private.
If "true", then the IP address is public and accessible from the internet.
If "false", then the IP address is private and accessible only from within the associated virtual cloud network.

Sample:
True
   
reserved_ip
complex
on success

     
id
string
on success
OCID of the reserved public IP address created with the virtual cloud network.
Reserved public IP addresses are IP addresses that are registered using the virtual cloud network API.
Create a reserved public IP address. When you create the network load balancer, enter the OCID of the reserved public IP address in the reservedIp field to attach the IP address to the network load balancer. This task configures the network load balancer to listen to traffic on this IP address.
Reserved public IP addresses are not deleted when the network load balancer is deleted. The IP addresses become unattached from the network load balancer.
Example: "ocid1.publicip.oc1.phx.unique_ID"

Sample:
ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
 
is_preserve_source_destination
boolean
on success
When enabled, the skipSourceDestinationCheck parameter is automatically enabled on the load balancer VNIC. Packets are sent to the backend set without any changes to the source and destination IP.

Sample:
True
 
is_private
boolean
on success
Whether the network load balancer has a virtual cloud network-local (private) IP address.
If "true", then the service assigns a private IP address to the network load balancer.
If "false", then the service assigns a public IP address to the network load balancer.
A public network load balancer is accessible from the internet, depending the security list rules for your virtual cloudn network. For more information about public and private network load balancers, see How Network Load Balancing Works. This value is true by default.
Example: `true`

Sample:
True
 
lifecycle_details
string
on success
A message describing the current state in more detail. For example, can be used to provide actionable information for a resource in Failed state.

Sample:
lifecycle_details_example
 
lifecycle_state
string
on success
The current state of the network load balancer.

Sample:
CREATING
 
listeners
complex
on success
Listeners associated with the network load balancer.

   
default_backend_set_name
string
on success
The name of the associated backend set.
Example: `example_backend_set`

Sample:
default_backend_set_name_example
   
ip_version
string
on success
IP version associated with the listener.

Sample:
IPV4
   
name
string
on success
A friendly name for the listener. It must be unique and it cannot be changed.
Example: `example_listener`

Sample:
name_example
   
port
integer
on success
The communication port for the listener.
Example: `80`

Sample:
56
   
protocol
string
on success
The protocol on which the listener accepts connection requests. For public network load balancers, ANY protocol refers to TCP/UDP. For private network load balancers, ANY protocol refers to TCP/UDP/ICMP (note that ICMP requires isPreserveSourceDestination to be set to true). To get a list of valid protocols, use the ListNetworkLoadBalancersProtocols operation.
Example: `TCP`

Sample:
ANY
 
network_security_group_ids
list / elements=string
on success
An array of network security groups OCIDs associated with the network load balancer.
During the creation of the network load balancer, the service adds the new load balancer to the specified network security groups.
The benefits of associating the network load balancer with network security groups include:
* Network security groups define network security rules to govern ingress and egress traffic for the network load balancer.
* The network security rules of other resources can reference the network security groups associated with the network load balancer to ensure access.
Example: ["ocid1.nsg.oc1.phx.unique_ID"]

 
nlb_ip_version
string
on success
IP version associated with the NLB.

Sample:
IPV4
 
subnet_id
string
on success
The subnet in which the network load balancer is spawned OCIDs."

Sample:
ocid1.subnet.oc1..xxxxxxEXAMPLExxxxxx
 
system_tags
dictionary
on success
Key-value pair representing system tags' keys and values scoped to a namespace. Example: `{"bar-key": "value"}`

 
time_created
string
on success
The date and time the network load balancer was created, in the format defined by RFC3339.
Example: `2020-05-01T21:10:29.600Z`

Sample:
2013-10-20T19:20:30+01:00
 
time_updated
string
on success
The time the network load balancer was updated. An RFC3339 formatted date-time string.
Example: `2020-05-01T22:10:29.600Z`

Sample:
2013-10-20T19:20:30+01:00


Authors

  • Oracle (@oracle)