W3cubDocs

/Ansible

community.digitalocean.digital_ocean_load_balancer – Manage DigitalOcean Load Balancers

Note

This plugin is part of the community.digitalocean collection (version 1.11.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 community.digitalocean.

To use it in a playbook, specify: community.digitalocean.digital_ocean_load_balancer.

New in version 1.10.0: of community.digitalocean

Synopsis

  • Manage DigitalOcean Load Balancers

Parameters

Parameter Choices/Defaults Comments
algorithm
string
    Choices:
  • round_robin
  • least_connections
The load balancing algorithm used to determine which backend Droplet will be selected by a client.
It must be either round_robin or least_connections.
droplet_ids
list / elements=integer
An array containing the IDs of the Droplets assigned to the load balancer.
Required when creating load balancers.
enable_backend_keepalive
boolean
    Choices:
  • no
  • yes
A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets.
enable_proxy_protocol
boolean
    Choices:
  • no
  • yes
A boolean value indicating whether PROXY Protocol is in use.
forwarding_rules
list / elements=dictionary
Default:
[{"certificate_id": "", "entry_port": 8080, "entry_protocol": "http", "target_port": 8080, "target_protocol": "http", "tls_passthrough": false}]
An array of objects specifying the forwarding rules for a load balancer.
Required when creating load balancers.
certificate_id
string
Default:
""
Certificate ID
entry_port
integer
Default:
8080
Entry port
entry_protocol
string
Default:
"http"
Entry protocol
target_port
integer
Default:
8080
Target port
target_protocol
string
Default:
"http"
Target protocol
tls_passthrough
boolean
    Choices:
  • no
  • yes
TLS passthrough
health_check
dictionary
Default:
{"check_interval_seconds": 10, "healthy_threshold": 5, "path": "/", "port": 80, "protocol": "http", "response_timeout_seconds": 5, "unhealthy_threshold": 3}
An object specifying health check settings for the load balancer.
check_interval_seconds
integer
Default:
10
Check interval seconds
healthy_threshold
integer
Default:
5
Healthy threshold
path
string
Default:
"/"
Path
port
integer
Default:
80
Port
protocol
string
Default:
"http"
Protocol
response_timeout_seconds
integer
Default:
5
Response timeout seconds
unhealthy_threshold
integer
Default:
3
Unhealthy threshold
name
string / required
A human-readable name for a load balancer instance.
Required and must be unique (current API documentation is not up-to-date for this parameter).
oauth_token
string / required
DigitalOcean OAuth token; can be specified in DO_API_KEY, DO_API_TOKEN, or DO_OAUTH_TOKEN environment variables

aliases: API_TOKEN
redirect_http_to_https
boolean
    Choices:
  • no
  • yes
A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443.
region
string
Default:
"nyc1"
The slug identifier for the region where the resource will initially be available.

aliases: region_id
size
string
    Choices:
  • lb-small
  • lb-medium
  • lb-large
The size of the load balancer.
The available sizes are lb-small, lb-medium, or lb-large.
You can resize load balancers after creation up to once per hour.
You cannot resize a load balancer within the first hour of its creation.
state
string
    Choices:
  • present
  • absent
The usual, present to create, absent to destroy
sticky_sessions
dictionary
Default:
{"type": "none"}
An object specifying sticky sessions settings for the load balancer.
type
string
Default:
"none"
Type
vpc_uuid
string
A string specifying the UUID of the VPC to which the load balancer is assigned.
If unspecified, uses the default VPC in the region.
wait
boolean
    Choices:
  • no
  • yes
Wait for the Load Balancer to be running before returning.
wait_timeout
integer
Default:
600
How long before wait gives up, in seconds, when creating a Load Balancer.

Examples

- name: Create a Load Balancer
  community.digitalocean.digital_ocean_load_balancer:
    state: present
    name: test-loadbalancer-1
    droplet_ids:
      - 12345678
    region: nyc1
    forwarding_rules:
      - entry_protocol: http
        entry_port: 8080
        target_protocol: http
        target_port: 8080
        certificate_id: ""
        tls_passthrough: false

Return Values

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

Key Returned Description
data
dictionary
changed
A DigitalOcean Load Balancer

Sample:
{'load_balancer': {'algorithm': 'round_robin', 'created_at': '2021-08-22T14:23:41Z', 'droplet_ids': [261172461], 'enable_backend_keepalive': False, 'enable_proxy_protocol': False, 'forwarding_rules': [{'certificate_id': '', 'entry_port': 8080, 'entry_protocol': 'http', 'target_port': 8080, 'target_protocol': 'http', 'tls_passthrough': False}], 'health_check': {'check_interval_seconds': 10, 'healthy_threshold': 5, 'path': '/', 'port': 80, 'protocol': 'http', 'response_timeout_seconds': 5, 'unhealthy_threshold': 3}, 'id': 'b4fdb507-70e8-4325-a89e-d02271b93618', 'ip': '159.203.150.113', 'name': 'test-loadbalancer-1', 'redirect_http_to_https': False, 'region': {'available': True, 'features': ['backups', 'ipv6', 'metadata', 'install_agent', 'storage', 'image_transfer'], 'name': 'New York 3', 'sizes': ['s-1vcpu-1gb', 's-1vcpu-1gb-amd', 's-1vcpu-1gb-intel', 's-1vcpu-2gb', 's-1vcpu-2gb-amd', 's-1vcpu-2gb-intel', 's-2vcpu-2gb', 's-2vcpu-2gb-amd', 's-2vcpu-2gb-intel', 's-2vcpu-4gb', 's-2vcpu-4gb-amd', 's-2vcpu-4gb-intel', 's-4vcpu-8gb', 'c-2', 'c2-2vcpu-4gb', 's-4vcpu-8gb-amd', 's-4vcpu-8gb-intel', 'g-2vcpu-8gb', 'gd-2vcpu-8gb', 's-8vcpu-16gb', 'm-2vcpu-16gb', 'c-4', 'c2-4vcpu-8gb', 's-8vcpu-16gb-amd', 's-8vcpu-16gb-intel', 'm3-2vcpu-16gb', 'g-4vcpu-16gb', 'so-2vcpu-16gb', 'm6-2vcpu-16gb', 'gd-4vcpu-16gb', 'so1_5-2vcpu-16gb', 'm-4vcpu-32gb', 'c-8', 'c2-8vcpu-16gb', 'm3-4vcpu-32gb', 'g-8vcpu-32gb', 'so-4vcpu-32gb', 'm6-4vcpu-32gb', 'gd-8vcpu-32gb', 'so1_5-4vcpu-32gb', 'm-8vcpu-64gb', 'c-16', 'c2-16vcpu-32gb', 'm3-8vcpu-64gb', 'g-16vcpu-64gb', 'so-8vcpu-64gb', 'm6-8vcpu-64gb', 'gd-16vcpu-64gb', 'so1_5-8vcpu-64gb', 'm-16vcpu-128gb', 'c-32', 'c2-32vcpu-64gb', 'm3-16vcpu-128gb', 'm-24vcpu-192gb', 'g-32vcpu-128gb', 'so-16vcpu-128gb', 'm6-16vcpu-128gb', 'gd-32vcpu-128gb', 'm3-24vcpu-192gb', 'g-40vcpu-160gb', 'so1_5-16vcpu-128gb', 'm-32vcpu-256gb', 'gd-40vcpu-160gb', 'so-24vcpu-192gb', 'm6-24vcpu-192gb', 'm3-32vcpu-256gb', 'so1_5-24vcpu-192gb', 'm6-32vcpu-256gb'], 'slug': 'nyc3'}, 'size': 'lb-small', 'status': 'active', 'sticky_sessions': {'type': 'none'}, 'tag': '', 'vpc_uuid': 'b8fd9a58-d93d-4329-b54a-78a397d64855'}}


Authors

  • Mark Mercado (@mamercad)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/digitalocean/digital_ocean_load_balancer_module.html