ansible.builtin.ec2_elb_lb (v2.9.17) — module

Creates, updates or destroys an Amazon ELB.

| "added in version" 1.5 of ansible.builtin"

Authors: Jim Dalton (@jsdalton)

stableinterface | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.17

Description

Returns information about the load balancer.

Will be marked changed when called only if state is changed.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Note: None of these examples set aws_access_key, aws_secret_key, or region.
# It is assumed that their matching environment variables are set.

# Basic provisioning example (non-VPC)

- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: present
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http # options are http, https, ssl, tcp
        load_balancer_port: 80
        instance_port: 80
        proxy_protocol: True
      - protocol: https
        load_balancer_port: 443
        instance_protocol: http # optional, defaults to value of protocol setting
        instance_port: 80
        # ssl certificate required for https or ssl
        ssl_certificate_id: "arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Internal ELB example

- local_action:
    module: ec2_elb_lb
    name: "test-vpc"
    scheme: internal
    state: present
    instance_ids:
      - i-abcd1234
    purge_instance_ids: true
    subnets:
      - subnet-abcd1234
      - subnet-1a2b3c4d
    listeners:
      - protocol: http # options are http, https, ssl, tcp
        load_balancer_port: 80
        instance_port: 80
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Configure a health check and the access logs
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: present
    zones:
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    health_check:
        ping_protocol: http # options are http, https, ssl, tcp
        ping_port: 80
        ping_path: "/index.html" # not required for tcp or ssl
        response_timeout: 5 # seconds
        interval: 30 # seconds
        unhealthy_threshold: 2
        healthy_threshold: 10
    access_logs:
        interval: 5 # minutes (defaults to 60)
        s3_location: "my-bucket" # This value is required if access_logs is set
        s3_prefix: "logs"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Ensure ELB is gone
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Ensure ELB is gone and wait for check (for default timeout)
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: absent
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Ensure ELB is gone and wait for check with timeout value
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: absent
    wait: yes
    wait_timeout: 600
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Normally, this module will purge any listeners that exist on the ELB
# but aren't specified in the listeners parameter. If purge_listeners is
# false it leaves them alone
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: present
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    purge_listeners: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Normally, this module will leave availability zones that are enabled
# on the ELB alone. If purge_zones is true, then any extraneous zones
# will be removed
- local_action:
    module: ec2_elb_lb
    name: "test-please-delete"
    state: present
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    purge_zones: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Creates a ELB and assigns a list of subnets to it.
- local_action:
    module: ec2_elb_lb
    state: present
    name: 'New ELB'
    security_group_ids: 'sg-123456, sg-67890'
    region: us-west-2
    subnets: 'subnet-123456,subnet-67890'
    purge_subnets: yes
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create an ELB with connection draining, increased idle timeout and cross availability
# zone load balancing
- local_action:
    module: ec2_elb_lb
    name: "New ELB"
    state: present
    connection_draining_timeout: 60
    idle_timeout: 300
    cross_az_load_balancing: "yes"
    region: us-east-1
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create an ELB with load balancer stickiness enabled
- local_action:
    module: ec2_elb_lb
    name: "New ELB"
    state: present
    region: us-east-1
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    stickiness:
      type: loadbalancer
      enabled: yes
      expiration: 300
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create an ELB with application stickiness enabled
- local_action:
    module: ec2_elb_lb
    name: "New ELB"
    state: present
    region: us-east-1
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    stickiness:
      type: application
      enabled: yes
      cookie: SESSIONID
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create an ELB and add tags
- local_action:
    module: ec2_elb_lb
    name: "New ELB"
    state: present
    region: us-east-1
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    tags:
      Name: "New ELB"
      stack: "production"
      client: "Bob"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Delete all tags from an ELB
- local_action:
    module: ec2_elb_lb
    name: "New ELB"
    state: present
    region: us-east-1
    zones:
      - us-east-1a
      - us-east-1d
    listeners:
      - protocol: http
        load_balancer_port: 80
        instance_port: 80
    tags: {}

Inputs

    
name:
    description:
    - The name of the ELB
    required: true
    type: str

tags:
    description:
    - An associative array of tags. To delete all tags, supply an empty dict.
    type: dict
    version_added: '2.1'
    version_added_collection: ansible.builtin

wait:
    default: false
    description:
    - When specified, Ansible will check the status of the load balancer to ensure it
      has been successfully removed from AWS.
    type: bool
    version_added: '2.1'
    version_added_collection: ansible.builtin

state:
    choices:
    - absent
    - present
    description:
    - Create or destroy the ELB
    required: true
    type: str

zones:
    description:
    - List of availability zones to enable on this ELB
    type: list

region:
    aliases:
    - aws_region
    - ec2_region
    description:
    - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION
      environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region)
    type: str

scheme:
    choices:
    - internal
    - internet-facing
    default: internet-facing
    description:
    - The scheme to use when creating the ELB. For a private VPC-visible ELB use 'internal'.
      If you choose to update your scheme with a different value the ELB will be destroyed
      and recreated. To update scheme you must use the option wait.
    type: str
    version_added: '1.7'
    version_added_collection: ansible.builtin

ec2_url:
    aliases:
    - aws_endpoint_url
    - endpoint_url
    description:
    - URL to use to connect to EC2 or your Eucalyptus cloud (by default the module will
      use EC2 endpoints). Ignored for modules where region is required. Must be specified
      for all other modules if region is not used. If not set then the value of the EC2_URL
      environment variable, if any, is used.
    type: str

profile:
    aliases:
    - aws_profile
    description:
    - Using I(profile) will override I(aws_access_key), I(aws_secret_key) and I(security_token)
      and support for passing them at the same time as I(profile) has been deprecated.
    - I(aws_access_key), I(aws_secret_key) and I(security_token) will be made mutually
      exclusive with I(profile) after 2022-06-01.
    type: str

subnets:
    description:
    - A list of VPC subnets to use when creating ELB. Zones should be empty if using this.
    type: list
    version_added: '1.7'
    version_added_collection: ansible.builtin

listeners:
    description:
    - List of ports/protocols for this ELB to listen on (see example)
    type: list

aws_config:
    description:
    - A dictionary to modify the botocore configuration.
    - Parameters can be found at U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config).
    - Only the 'user_agent' key is used for boto modules. See U(http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto)
      for more boto configuration.
    type: dict

stickiness:
    description:
    - An associative array of stickiness policy settings. Policy will be applied to all
      listeners ( see example )
    type: dict
    version_added: '2.0'
    version_added_collection: ansible.builtin

access_logs:
    description:
    - An associative array of access logs configuration settings (see example)
    type: dict
    version_added: '2.0'
    version_added_collection: ansible.builtin

purge_zones:
    default: false
    description:
    - Purge existing availability zones on ELB that are not found in zones
    type: bool

health_check:
    description:
    - An associative array of health check configuration settings (see example)
    type: dict

idle_timeout:
    description:
    - ELB connections from clients and to servers are timed out after this amount of time
    type: int
    version_added: '2.0'
    version_added_collection: ansible.builtin

instance_ids:
    description:
    - List of instance ids to attach to this ELB
    type: list
    version_added: '2.1'
    version_added_collection: ansible.builtin

wait_timeout:
    default: 60
    description:
    - Used in conjunction with wait. Number of seconds to wait for the elb to be terminated.
      A maximum of 600 seconds (10 minutes) is allowed.
    type: int
    version_added: '2.1'
    version_added_collection: ansible.builtin

aws_ca_bundle:
    description:
    - The location of a CA Bundle to use when validating SSL certificates.
    - Not used by boto 2 based modules.
    - 'Note: The CA Bundle is read ''module'' side and may need to be explicitly copied
      from the controller if not run locally.'
    type: path

purge_subnets:
    default: false
    description:
    - Purge existing subnet on ELB that are not found in subnets
    type: bool
    version_added: '1.7'
    version_added_collection: ansible.builtin

aws_access_key:
    aliases:
    - ec2_access_key
    - access_key
    description:
    - C(AWS access key). If not set then the value of the C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY)
      or C(EC2_ACCESS_KEY) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(aws_access_key) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-01.
    type: str

aws_secret_key:
    aliases:
    - ec2_secret_key
    - secret_key
    description:
    - C(AWS secret key). If not set then the value of the C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY),
      or C(EC2_SECRET_KEY) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(aws_secret_key) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-01.
    type: str

security_token:
    aliases:
    - aws_security_token
    - access_token
    description:
    - C(AWS STS security token). If not set then the value of the C(AWS_SECURITY_TOKEN)
      or C(EC2_SECURITY_TOKEN) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(security_token) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-01.
    type: str

validate_certs:
    default: true
    description:
    - When set to C(no), SSL certificates will not be validated for boto versions >= 2.6.0.
    type: bool
    version_added: '1.5'
    version_added_collection: ansible.builtin

purge_listeners:
    default: true
    description:
    - Purge existing listeners on ELB that are not found in listeners
    type: bool

purge_instance_ids:
    default: false
    description:
    - Purge existing instance ids on ELB that are not found in instance_ids
    type: bool
    version_added: '2.1'
    version_added_collection: ansible.builtin

security_group_ids:
    description:
    - A list of security groups to apply to the elb
    type: list
    version_added: '1.6'
    version_added_collection: ansible.builtin

security_group_names:
    description:
    - A list of security group names to apply to the elb
    type: list
    version_added: '2.0'
    version_added_collection: ansible.builtin

cross_az_load_balancing:
    default: false
    description:
    - Distribute load across all configured Availability Zones
    type: bool
    version_added: '1.8'
    version_added_collection: ansible.builtin

connection_draining_timeout:
    description:
    - Wait a specified timeout allowing connections to drain before terminating an instance
    type: int
    version_added: '1.8'
    version_added_collection: ansible.builtin

debug_botocore_endpoint_logs:
    default: 'no'
    description:
    - Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action"
      API calls made during a task, outputing the set to the resource_actions key in the
      task results. Use the aws_resource_action callback to output to total list made
      during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also
      be used.
    type: bool