oci_load_balancer - Create, update and delete load balancers in OCI Load Balancing Service

New in version 2.5.

Synopsis

  • Creates OCI Load Balancers
  • Update OCI Load Balancers, if present, with a new display name
  • Delete OCI Load Balancers, if present.

Requirements

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

Parameters

Parameter Choices/Defaults Comments
api_user
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_OCID 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
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
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
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_type
    Choices:
  • api_key ←
  • instance_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.
backend_sets
The configuration details for a load balancer's backend sets
policy
required
The load balancer policy for the backend set.
ssl_configuration
The load balancer's SSL handling configuration details. This should be specified as a dict/hash with the following keys [certificate_name describes a friendly name for the certificate bundle. It must be unique and it cannot be changed. Valid certificate bundle names include only alphanumeric characters, dashes, and underscores.Certificate bundle names cannot contain spaces. required - true], ['verify_depth' describes the maximum depth for peer certificate chain verification. required - false], ['verify_peer_certificate' describes whether the load balancer listener should verify peer certificates. required - false]
backends
A list of configurations related to Backends that are part of a backend set. Each Backend's configuration should be a dict/hash that consist of the following keys ['backup' option specifies whether the load balancer should treat this server as a backup unit. If true, the load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "backup" fail the health check policy. required - false],['drain' option specifies whether the load balancer should drain this server. Servers marked "drain" receive no new incoming traffic. required - false], [ip_address describes the IP address of the backend server. required - true], ['offline' ensures whether the load balancer should treat this server as offline. Offline servers receive no incoming traffic. required - false], ['port' describes the communication port for the backend server. required - true], [ 'weight' describes the 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 3 times the number of new connections as a server weighted '1'. required - false]
health_checker
required
Describes the health check policy for a backend set. This should be a dict/hash that consists of the following keys ['interval_in_millis' describes the interval between health checks, in milliseconds. required - false], [ 'port' describes the backend server port against which to run the health check. If the port is not specified, the load balancer uses the port information from the backends mentioned above. required - false], ['protocol' describes the protocol the health check must use, either HTTP or TCP. required - true], [ 'response_body_regex' describes a regular expression for parsing the response body from the backend server. required - false], ['retries' describes the number of retries to attempt before a backend server is considered unhealthy. required - false], ['return_code' describes the status code a healthy backend server should return. required - false], ['timeout_in_millis' describes 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. required - false], ['url_path' describes the path against which to run the health check. required - true]
session_persistence_configuration
The configuration details for implementing session persistence. Session persistence enables the Load Balancing Service to direct any number of requests that originate from a single logical client to a single backend web server. This should be specified as a dict/hash with the following keys ['cookie_name' describes the name of the cookie used to detect a session initiated by the backend server. Use '*' to specify that any cookie set by the backend causes the session to persist. required - true], ['disable_fallback' describes Whether the load balancer is prevented from directing traffic from a persistent session client to a different backend server if the original server is unavailable. Defaults to false. required - false]
certificates
The configuration details for a listener certificate bundle.
certificate_name
required
A friendly name for the certificate bundle. It must be unique and it cannot be changed. Valid certificate bundle names include only alphanumeric characters, dashes, and underscores. Certificate bundle names cannot contain spaces.
private_key
The SSL private key for your certificate, in PEM format.
ca_certificate
The Certificate Authority certificate, or any interim certificate, that you received from your SSL certificate provider.
passphrase
A passphrase for encrypted private keys. This is needed only if you created your certificate with a passphrase.
public_certificate
The public certificate, in PEM format, that you received from your SSL certificate provider.
compartment_id
Identifier of the compartment under which this Load Balancer would be created. Mandatory for create operation.Optional for delete and update. Mutually exclusive with oci_load_balancer_id.
config_file_location
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
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.
display_name
Name of the Load Balancer. A user friendly name. Does not have to be unique, and could be changed. Mandatory for create and update.

aliases: name
force_create
bool
    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.
hostnames
The details of a hostname resource associated with a load balancer.
hostname
required
A virtual hostname.
name
required
The name of the hostname resource.
is_private
bool
    Choices:
  • no
  • yes
Defines whether the load balancer has a VCN-local (private) IP address.
key_by
The list of comma-separated attributes of this resource which should be used to uniquely identify an instance of the resource. By default, all the attributes of a resource except freeform_tags are used to uniquely identify a resource.
listeners
The listener configuration details.
ssl_configuration
The load balancer SSL handling configuration details. Consists of following options, ['certificate_name' describes a friendly name for the certificate bundle. It must be unique and it cannot be changed. Valid certificate bundle names include only alphanumeric characters, dashes, and underscores.Certificate bundle names cannot contain spaces. required - true],['verify_depth' describes the maximum depth for peer certificate chain verification. required - false], ['verify_peer_certificate' describes whether the load balancer listener should verify peer certificates. required - false]
path_route_set_name
The name of the set of path-based routing rules, PathRouteSet, applied to this listener's traffic.
protocol
required
The protocol on which the listener accepts connection requests.
default_backend_set_name
required
The name of the associated backend set.
hostname_names
An array of hostname resource names.
connection_configuration
Configuration details for the connection between the client and backend servers. Consists of following options, ['idle_timeout' describes The maximum idle time, in seconds, allowed between two successive receive or two successive send operations between the client and backend servers. A send operation does not reset the timer for receive operations. A receive operation does not reset the timer for send operations.]
port
required
The communication port for the listener.
load_balancer_id
Identifier of the Load Balancer. Mandatory for delete and update.

aliases: id
path_route_sets
The configuration details for a load balancer's path route sets
path_routes
A list of configurations related to Path Routes that are part of a path route set. Each Path Route's configuration should be a dict/hash that consist of the following keys ['backend_set_name' option specifies The name of the target backend set for requests where the incoming URI matches the specified path.required - true],['path' option specifies the path string to match against the incoming URI path. required - true], ['path_match_type' describes the type of matching to apply to incoming URIs.The value of this attribute is another dict/hash with 'match_type' is key and value is one of EXACT_MATCH, FORCE_LONGEST_PREFIX_MATCH, PREFIX_MATCH, SUFFIX_MATCH. required - true]
region
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.
shape_name
required
A template that determines the total pre-provisioned bandwidth (ingress plus egress).
state
    Choices:
  • present ←
  • absent
Create,update or delete Load Balancer. For state=present, if it does not exists, it gets created. If exists, it gets updated.
subnet_ids
required
An array of subnet OCIDs.
tenancy
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
bool
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout Default:
1200
Time, in seconds, to wait when wait=yes.
wait_until
The lifecycle state to wait for the resource to transition into when wait=yes. By default, when wait=yes, we wait for the resource to get into ACTIVE/ATTACHED/AVAILABLE/PROVISIONED/ RUNNING applicable lifecycle state during create operation & to get into DELETED/DETACHED/ TERMINATED lifecycle state during delete operation.

Examples

# Note: These examples do not set authentication details.
# Create Load Balancer
- name: Create Load Balancer
  oci_load_balancer:
    compartment_id: "ocid1.compartment.xvds"
    name: "ansible_lb"
    backend_sets:
     backend1:
      backends:
          - ip_address: "10.159.34.21"
            port: "8080"
      health_checker:
          interval_in_millis: "30000"
          port: "8080"
          protocol: "HTTP"
          response_body_regex: "^(500|40[1348])$"
          retries: "3"
          timeout_in_millis: "6000"
          return_code: "200"
          url_path: "/healthcheck"
      policy: "LEAST_CONNECTIONS"
    shape_name: "100Mbps"
    listeners:
      listerner1:
        default_backend_set_name: "backend1"
        port: "80"
        protocol: "HTTP"
        hostname_names: ['hostname_001']
        path_route_set_name: 'test_path_route_set'
    subnet_ids:
        - "ocid1.subnet.ad1"
        - "ocid1.subnet.ad2"
    certificates:
        certs1:
            ca_certificate: "fullchain.pem"
            private_key: "privkey.pem"
            public_certificate: "ca_cert.pem"
            certificate_name: "certs1"
    path_route_sets:
          test_path_route_set:
              path_routes:
                  - backend_set_name: "backend1"
                    path: "/admin"
                    path_match_type:
                       match_type: 'EXACT_MATCH'
    hostnames:
       ansible_hostname:
           name: 'ansible_hostname'
           hostname: 'myapp.example.com'
    state: 'present'
# Update Load Balancer
- name: Update Load Balancer
  oci_load_balancer:
    load_balancer_id: "ocid1.loadbalancer.oc1.iad.xxxxxEXAMPLExxxxx"
    name: "ansible_lb_updated"
    state: 'present'
# Deleted Load Balancer
- name: Update Load Balancer
  oci_load_balancer:
    load_balancer_id: "ocid1.loadbalancer.oc1.iad.xxxxxEXAMPLExxxxx"
    state: 'absent'

Return Values

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

Key Returned Description
load_balancer
complex
success
Attributes of the created/updated Load Balancer. For delete, deleted Load Balancer description will be returned.

Sample:
{'lifecycle_state': 'ACTIVE', 'display_name': 'ansible_lb955', 'shape_name': '100Mbps', 'compartment_id': 'ocid1.compartment.oc1..xxxxxEXAMPLExxxxx', 'ip_addresses': [{'is_public': True, 'ip_address': '129.213.72.32'}], 'time_created': '2018-01-06T18:22:17.198000+00:00', 'id': 'ocid1.loadbalancer.oc1.iad.xxxxxEXAMPLExxxxx', 'listeners': {'listerner1': {'ssl_configuration': None, 'protocol': 'HTTP', 'name': 'listerner1', 'default_backend_set_name': 'backend1', 'connection_configuration': {'idle_timeout': 1200}, 'port': 80}}, 'hostnames': {'ansible_hostname': {'hostname': 'app.example.com', 'name': 'ansible_hostname'}}, 'certificates': {'certs1': {'certificate_name': 'certs1', 'public_certificate': '-----BEGIN CERTIFICATE-----\nMIIFKTCCBBGgAwIBAgISBIs5aiZ1fWapuAl2P9POFMXjMA0GCSqGSIb3DQEBCwUA\n- ----END CERTIFICATE-----', 'ca_certificate': '-----BEGIN CERTIFICATE-----\nMIIFKTCCBBGgAwIBAgISBIs5aiZ1fWapuAl2P9POFMXjMA0GCSqGSIb3DQEBCwUA\n-----END CERTIFICATE -----\n-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----'}}, 'subnet_ids': ['ocid1.subnet.oc1.iad.xxxxxEXAMPLExxxxx', 'ocid1.subnet.oc1.iad.xxxxxEXAMPLExxxxx'], 'backend_sets': {'backend1': {'ssl_configuration': None, 'backends': [{'drain': False, 'name': '10.159.34.21:8080', 'weight': 1, 'ip_address': '10.159.34.21', 'offline': False, 'backup': False, 'port': 8080}], 'health_checker': {'retries': 3, 'protocol': 'HTTP', 'response_body_regex': '^(500|40[1348])$', 'return_code': 200, 'timeout_in_millis': 6000, 'interval_in_millis': 30000, 'url_path': '/healthcheck', 'port': 8080}, 'name': 'backend1', 'policy': 'LEAST_CONNECTIONS', 'session_persistence_configuration': None}}, 'path_route_sets': {'ansible_path_route_set': {'path_routes': [{'path': '/example/user', 'backend_set_name': 'ansible_backend_set', 'path_match_type': {'match_type': 'EXACT_MATCH'}}]}}, 'is_private': False}
  lifecycle_state
string
always
The current state of the Load Balancer

Sample:
ACTIVE
  display_name
string
always
Name assigned to the Load Balancer during creation

Sample:
ansible_lb
  shape_name
string
always
A template that determines the total pre-provisioned bandwidth (ingress plus egress).

Sample:
100Mbps
  compartment_id
string
always
The identifier of the compartment containing the Load Balancer

Sample:
ocid1.compartment.oc1.xzvf..oifds
  time_created
datetime
always
Date and time when the Load Balancer was created, in the format defined by RFC3339

Sample:
2016-08-25 21:10:29.600000
  id
string
always
Identifier of the Load Balancer

Sample:
ocid1.loadbalancer.oc1.iad.xxxxxEXAMPLExxxxx
  sample

  listeners
dict
always
The listener configuration details.

Sample:
{'listerner1': {'ssl_configuration': None, 'protocol': 'HTTP', 'name': 'listerner1', 'default_backend_set_name': 'backend1', 'connection_configuration': {'idle_timeout': 1200}, 'port': 80}}
  hostnames
dict
always
The details of a hostname resource associated with a load balancer.

Sample:
{'ansible_hostname': {'hostname': 'app.example.com', 'name': 'ansible_hostname'}}
  certificates
dict
always
The configuration details for a listener certificate bundle.

Sample:
{'certs1': {'certificate_name': 'certs1', 'public_certificate': '-----BEGIN CERTIFICATE-----\nMIIFKTCCBBGgAwIBAgISBIs5aiZ1fWapuAl2P9POFMXjMA0GCSqGSIb3DQEBCwUA\n -----END CERTIFICATE-----', 'ca_certificate': '-----BEGIN CERTIFICATE-----\nMIIFKTCCBBGgAwIBAgISBIs5aiZ1fWapuAl2P9POFMXjMA0GCSqGSIb3DQEBCwUA\n -----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----'}}
  subnet_ids
list
always
An array of subnet OCIDs.

Sample:
['ocid1.subnet.oc1.iad.xxxxxEXAMPLExxxxx', 'ocid1.subnet.oc1.iad.xxxxxEXAMPLExxxxx']
  backend_sets
dict
always
The configuration details for a load balancer backend set

Sample:
{'backend1': {'backends': [{'drain': False, 'name': '10.159.34.21:8080', 'weight': 1, 'ip_address': '10.159.34.21', 'offline': False, 'backup': False, 'port': 8080}], 'health_checker': {'retries': 3, 'protocol': 'HTTP', 'name': 'backend1', 'response_body_regex': '^(500|40[1348])$', 'return_code': 200, 'ssl_configuration': None, 'timeout_in_millis': 6000, 'policy': 'LEAST_CONNECTIONS', 'interval_in_millis': 30000, 'url_path': '/healthcheck', 'port': 8080, 'session_persistence_configuration': None}}}
  path_route_sets
dict
always
The path route sets configuration details.



Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • Debayan Gupta(@debayan_gupta)

Hint

If you notice any issues in this documentation you can edit this document to improve it.