community.digitalocean.digital_ocean_load_balancer (1.26.0) — module

Manage DigitalOcean Load Balancers

| "added in version" 1.10.0 of community.digitalocean"

Authors: Mark Mercado (@mamercad)

Install collection

Install with ansible-galaxy collection install community.digitalocean:==1.26.0


Add to requirements.yml

  collections:
    - name: community.digitalocean
      version: 1.26.0

Description

Manage DigitalOcean Load Balancers

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a Load Balancer (and assign to Project "test")
  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
    project: test
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a Load Balancer and associate it with a tag
  community.digitalocean.digital_ocean_load_balancer:
    state: present
    name: test-loadbalancer-1
    tag: test-tag
    region: tor1

Inputs

    
tag:
    description:
    - A tag associated with the droplets that you want to dynamically assign to the load
      balancer.
    - Required when creating load balancers.
    - Mutually exclusive with droplet_ids, you can either define tag or droplet_ids but
      not both.
    required: false
    type: str

name:
    description:
    - 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).
    required: true
    type: str

size:
    choices:
    - lb-small
    - lb-medium
    - lb-large
    default: lb-small
    description:
    - The size of the load balancer.
    - The available sizes are C(lb-small), C(lb-medium), or C(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.
    - This field has been replaced by the C(size_unit) field for all regions except in
      C(ams2), C(nyc2), and C(sfo1).
    - Each available load balancer size now equates to the load balancer having a set
      number of nodes.
    - The formula is C(lb-small) = 1 node, C(lb-medium) = 3 nodes, C(lb-large) = 6 nodes.
    required: false
    type: str

wait:
    default: true
    description:
    - Wait for the Load Balancer to be running before returning.
    required: false
    type: bool

state:
    choices:
    - present
    - absent
    default: present
    description:
    - The usual, C(present) to create, C(absent) to destroy
    type: str

region:
    aliases:
    - region_id
    description:
    - The slug identifier for the region where the resource will initially be available.
    required: false
    type: str

baseurl:
    default: https://api.digitalocean.com/v2
    description:
    - DigitalOcean API base url.
    type: str

timeout:
    default: 30
    description:
    - The timeout in seconds used for polling DigitalOcean's API.
    type: int

vpc_uuid:
    description:
    - A string specifying the UUID of the VPC to which the load balancer is assigned.
    - If unspecified, uses the default VPC in the region.
    required: false
    type: str

size_unit:
    default: 1
    description:
    - How many nodes the load balancer contains.
    - Each additional node increases the load balancer's ability to manage more connections.
    - Load balancers can be scaled up or down, and you can change the number of nodes
      after creation up to once per hour.
    - This field is currently not available in the C(ams2), C(nyc2), or C(sfo1) regions.
    - Use the C(size) field to scale load balancers that reside in these regions.
    - The value must be in the range 1-100.
    required: false
    type: int

droplet_ids:
    description:
    - An array containing the IDs of the Droplets assigned to the load balancer.
    - Required when creating load balancers.
    - Mutually exclusive with tag, you can either define tag or droplet_ids but not both.
    elements: int
    required: false
    type: list

oauth_token:
    aliases:
    - api_token
    description:
    - DigitalOcean OAuth token.
    - There are several other environment variables which can be used to provide this
      value.
    - i.e., - C(DO_API_TOKEN), C(DO_API_KEY), C(DO_OAUTH_TOKEN) and C(OAUTH_TOKEN).
    type: str

health_check:
    default:
      check_interval_seconds: 10
      healthy_threshold: 5
      path: /
      port: 80
      protocol: http
      response_timeout_seconds: 5
      unhealthy_threshold: 3
    description:
    - An object specifying health check settings for the load balancer.
    required: false
    suboptions:
      check_interval_seconds:
        default: 10
        description: Check interval seconds
        required: false
        type: int
      healthy_threshold:
        default: 5
        description: Healthy threshold
        required: false
        type: int
      path:
        default: /
        description: Path
        required: false
        type: str
      port:
        default: 80
        description: Port
        required: false
        type: int
      protocol:
        default: http
        description: Protocol
        required: false
        type: str
      response_timeout_seconds:
        default: 5
        description: Response timeout seconds
        required: false
        type: int
      unhealthy_threshold:
        default: 3
        description: Unhealthy threshold
        required: false
        type: int
    type: dict

project_name:
    aliases:
    - project
    default: ''
    description:
    - Project to assign the resource to (project name, not UUID).
    - Defaults to the default project of the account (empty string).
    - Currently only supported when creating.
    required: false
    type: str

wait_timeout:
    default: 600
    description:
    - How long before wait gives up, in seconds, when creating a Load Balancer.
    type: int

validate_certs:
    default: true
    description:
    - If set to C(no), the SSL certificates will not be validated.
    - This should only set to C(no) used on personally controlled sites using self-signed
      certificates.
    type: bool

sticky_sessions:
    default:
      type: none
    description:
    - An object specifying sticky sessions settings for the load balancer.
    required: false
    suboptions:
      type:
        default: none
        description: Type
        required: false
        type: str
    type: dict

forwarding_rules:
    default:
    - certificate_id: ''
      entry_port: 8080
      entry_protocol: http
      target_port: 8080
      target_protocol: http
      tls_passthrough: false
    description:
    - An array of objects specifying the forwarding rules for a load balancer.
    - Required when creating load balancers.
    elements: dict
    required: false
    suboptions:
      certificate_id:
        default: ''
        description: Certificate ID
        type: str
      entry_port:
        default: 8080
        description: Entry port
        type: int
      entry_protocol:
        default: http
        description: Entry protocol
        type: str
      target_port:
        default: 8080
        description: Target port
        type: int
      target_protocol:
        default: http
        description: Target protocol
        type: str
      tls_passthrough:
        default: false
        description: TLS passthrough
        type: bool
    type: list

enable_proxy_protocol:
    default: false
    description:
    - A boolean value indicating whether PROXY Protocol is in use.
    required: false
    type: bool

redirect_http_to_https:
    default: false
    description:
    - A boolean value indicating whether HTTP requests to the load balancer on port 80
      will be redirected to HTTPS on port 443.
    required: false
    type: bool

enable_backend_keepalive:
    default: false
    description:
    - A boolean value indicating whether HTTP keepalive connections are maintained to
      target Droplets.
    required: false
    type: bool

Outputs

assign_status:
  description: Assignment status (ok, not_found, assigned, already_assigned, service_down)
  returned: changed
  sample: assigned
  type: str
data:
  description: A DigitalOcean Load Balancer
  returned: changed
  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
  type: dict
msg:
  description: Informational or error message encountered during execution
  returned: changed
  sample: No project named test2 found
  type: str
resources:
  description: Resource assignment involved in project assignment
  returned: changed
  sample:
    assigned_at: '2021-10-25T17:39:38Z'
    links:
      self: https://api.digitalocean.com/v2/load_balancers/17d171d0-8a8b-4251-9c18-c96cc515d36d
    status: assigned
    urn: do:loadbalancer:17d171d0-8a8b-4251-9c18-c96cc515d36d
  type: dict