New in version 1.5.0.
The below requirements are needed on the host that executes this module.
| Parameter | Choices/Defaults | Comments | |
|---|---|---|---|
| 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 |
||
|
backend_servers
required |
List of hash/dictionary of backend servers to add or set in when
state=presentList IDs of backend servers which in the load balancer when
state=absentaliases: servers |
||
|
server_id
required |
The ID of ecs instance which is added into load balancer.
|
||
| weight |
100
|
The weight of backend server in the load balancer.
|
|
|
load_balancer_id
required |
The unique ID of a Server Load Balancer instance
aliases: lb_id |
||
| state |
|
Add or remove backend server to/from a specified slb
|
|
Note
ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKENALICLOUD_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# Provisioning new add or remove Backend Server from SLB
# Basic example to add backend server to load balancer instance
- name: add backend server
hosts: localhost
connection: local
vars:
load_balancer_id: lb-abcd1234
tasks:
- name: add backend server
ali_slb_server:
load_balancer_id: '{{ load_balancer_id }}'
backend_servers:
- server_id: i-abcd1234
weight: 70
- server_id: i-abce1245
#Basic example to set backend server of load balancer instance
- name: set backend server
hosts: localhost
connection: local
vars:
alicloud_access_key: <your-alicloud-access-key-id>
alicloud_secret_key: <your-alicloud-access-secret-key>
tasks:
- name: set backend server
ali_slb_server:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
load_balancer_id: lb-abcd1234
backend_servers:
- server_id: i-abcd1234
weight: 50
- server_id: i-abcd1234
weight: 80
#Basic example to remove backend servers from load balancer instance
- name: remove backend servers
hosts: localhost
connection: local
tasks:
- name: remove backend servers
ali_slb_server:
load_balancer_id: lb-abcd1234
state: absent
backend_servers:
- i-abcd1234
- i-abcd1234
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
|
backend_servers
list
|
when success |
Details about the backened-servers that were added.
Sample:
[{'health_status': 'abnormal', 'id': 'i-2zeau2evvbnwufq0fa7q'}, {'health_status': 'abnormal', 'id': 'i-2zehasnejqr6g6agys5a'}]
|
|
load_balancer_id
string
|
when success |
ID of the load balancer.
Sample:
lb-2zeyfm5a14c9ffxvxmvco
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Hint
If you notice any issues in this documentation you can edit this document to improve it.