Documentation

ali_slb_lb - Create, Delete, Enable or Disable Server Load Balancer.

New in version 2.8.

Synopsis

  • Create, Delete, Start or Stop Server Load Balancer.
  • Modify Load Balancer internet charge type and bandwidth

Requirements

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

  • footmark >= 1.9.0
  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
address_type
(deprecated) The field has been deprecated from ansible-alicloud v1.1.3 and 'is_internet' will replace.
alicloud_access_key
Aliyun Cloud access key. If not set then the value of environment variable ALICLOUD_ACCESS_KEY, ALICLOUD_ACCESS_KEY_ID will be used instead.

aliases: access_key_id, access_key
alicloud_region
The Aliyun Cloud region to use. If not specified then the value of environment variable ALICLOUD_REGION, ALICLOUD_REGION_ID will be used instead.

aliases: region, region_id
alicloud_secret_key
Aliyun Cloud secret key. If not set then the value of environment variable ALICLOUD_SECRET_KEY, ALICLOUD_SECRET_ACCESS_KEY will be used instead.

aliases: secret_access_key, secret_key
alicloud_security_token
The Aliyun Cloud security token. If not specified then the value of environment variable ALICLOUD_SECURITY_TOKEN will be used instead.

aliases: security_token
bandwidth Default:
1
Bandwidth peak of the public network instance charged per fixed bandwidth. It allow 1~5000 in Mbps.
It will be ignored when internet_charge_type=PayByTraffic
internet_charge_type
    Choices:
  • PayByBandwidth
  • PayByTraffic ←
The charge type of internet. It will be ignored when is_internet=False
is_internet
bool
    Choices:
  • no ←
  • yes
Load balancer network type whether is internet.
load_balancer_id
(deprecated) This parameter is required when user wants to perform edit operation in Load Balancer

aliases: id
load_balancer_name
required
The name of the server load balancer, which is a string of 1 to 80 characters. It can contain numerals, "_", "/", "." or "-".
This is used to ensure idempotence.

aliases: name, lb_name
load_balancer_spec
    Choices:
  • slb.s1.small
  • slb.s2.small
  • slb.s2.medium
  • slb.s3.small
  • slb.s3.medium
  • slb.s3.large
The specification of the Server Load Balancer instance. If no value is specified, a shared-performance instance is created.
There are some region limitations for load_balancer_spec. See https://www.alibabacloud.com/help/doc-detail/27577.htm for details

aliases: spec, lb_spec
load_balancer_status
(deprecated) The field has been deprecated from ansible-alicloud v1.1.3.
master_zone_id
The ID of the primary zone. By default, the SLB cluster in the primary zone is used to distribute traffic.
multi_ok
bool
    Choices:
  • no ←
  • yes
By default the module will not create another Load Balancer if there is another Load Balancer with the same name. Specify this as true if you want duplicate Load Balancers created.
slave_zone_id
The ID of the backup zone. The backup zone takes over the traffic distribution only when the SLB cluster in the primary zone fails.
state
    Choices:
  • present ←
  • absent
  • running
  • stopped
The state of the instance after operating.
vswitch_id
The ID of the VSwitch to which the SLB instance belongs.

aliases: subnet_id

Notes

Note

  • The change in internet charge type will take effect from the early morning of the next day. It can not be changed twice in one day, otherwise, a error “Operation.NotAllowed” will appear.
  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKEN
  • ALICLOUD_REGION or ALICLOUD_REGION_ID can be typically be used to specify the ALICLOUD region, when required, but this can also be configured in the footmark config file

Examples

# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details.
- name: create a server load balancer
  ali_slb_lb:
    name: 'from-ansible'
    is_internet: True
    internet_charge_type: 'PayByTraffic'
    spec: 'slb.s1.small'
    state: present

- name: stop a server load balancer
  ali_slb_lb:
    name: 'from-ansible'
    state: stopped

- name: start a server load balancer
  ali_slb_lb:
    name: 'from-ansible'
    state: running

- name: modify server load balancer internet charge type and bandwidth
  ali_slb_lb:
    name: 'from-ansible'
    internet_charge_type: 'PayByBandwidth'
    bandwidth: 5

Return Values

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

Key Returned Description
load_balancer
complex
on present
info about the server load balancer that was created or deleted.

  resource_group_id
string
always
The resource group of the load balancer belongs.

Sample:
rg-acfmwvvtg5owavy
  master_zone_id
string
always
The ID of the primary zone.

Sample:
cn-beijing-a
  internet_charge_type
string
always
The load balancer internet charge type

Sample:
PayByTraffic
  tags
complex
always
The load balancer tags

  bandwidth
int
always
The load balancer internet bandwidth

Sample:
5
  create_time
string
always
The time of the load balancer was created

Sample:
2019-01-02T02:37:41Z
  address
string
always
The IP address of the loal balancer

Sample:
47.94.26.126
  address_ipversion
string
always
The IP address version. IPV4 or IPV6.

Sample:
ipv4
  id
string
always
The ID of the load balancer was created. Same as load_balancer_id.

Sample:
lb-2zea9ohgtf
  backend_servers
complex
always
The load balancer's backend servers

    server_id
string
always
The backend server id

Sample:
i-vqunci342
    type
string
always
The backend server type, ecs or eni

Sample:
ecs
    description
string
always
The backend server description

    weight
int
always
The backend server weight

Sample:
100
  pay_type
string
always
The load balancer instance charge type.

Sample:
PostPaid
  slave_zone_id
string
always
The ID of the backup zone

Sample:
cn-beijing-d
  name
string
always
The name of the load balancer was created.

Sample:
ansible-ali_slb_lb
  load_balancer_status
string
always
The load balancer current status.

Sample:
active
  load_balancer_name
string
always
The name of the load balancer was created.

Sample:
ansible-ali_slb_lb
  listeners
complex
always
The listeners of the load balancer.

    listener_port
int
always
The front-end port of the listener that is used to receive incoming traffic and distribute the traffic to the backend servers.

Sample:
22
    listener_protocol
string
always
The frontend protocol used by the SLB instance.

Sample:
tcp
    listener_forward
string
always
Whether to enable listener forwarding.

    forward_port
int
always
The destination listening port. It must be an existing HTTPS listening port.

Sample:
20
  end_time
string
always
The time of the load balancer will be released

Sample:
2999-09-08T16:00:00Z
  load_balancer_id
string
always
The ID of the load balancer was created.

Sample:
lb-2zea9ohgtf
  vpc_id
string
always
The vpc of the load balancer belongs.

Sample:
vpc-fn3nc3
  address_type
string
always
The load balancer internet type

Sample:
internet
  vswitch_id
string
always
The vswitch of the load balancer belongs.

Sample:
vsw-c3nc3r
  network_type
string
always
The network type of the load balancer was created.

Sample:
classic


Status

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

Author

  • He Guimin (@xiaozhu36)

Hint

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