Documentation

ali_ess_rule - Create or Terminate an scaling rule in ESS.

New in version 1.5.0.

Synopsis

  • A scaling rule defines specific scaling actions, for example, adding or removing n ECS instances. If the execution of a scaling rule results in a number of ECS instances in the scaling group that is less than the MinSize or greater than the MaxSize, Auto Scaling automatically adjusts the number of ECS instances to be added or removed by executing the “Adjust scaling group instance quantity to MinSize” or “Adjust scaling group instance quantity to MaxSize” rule.

Requirements

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

  • footmark >= 1.3.0
  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
adjustment_type
    Choices:
  • QuantityChangeInCapacity
  • PercentChangeInCapacity
  • TotalCapacity
Adjustment mode of a scaling rule.
QuantityChangeInCapacity used to increase or decrease a specified number of ECS instances;
PercentChangeInCapacity used to increase or decrease a specified proportion of ECS instances;
TotalCapacity used to adjust the quantity of ECS instances in the current scaling group to a specified value.
Required when state=present.

aliases: type
adjustment_value
Adjusted value of a scaling rule.
QuantityChangeInCapacity to (0, 100] U (-100, 0];
PercentChangeInCapacity to [0, 10000] U [-10000, 0];
TotalCapacity to [0, 100].
Required when state=present.

aliases: value
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
cooldown
Cool-down time of a scaling rule. Value range to [0, 86400], in seconds. The default value is empty.
group_id
ID of the scaling group of a scaling rule. Required when state=present.

aliases: scaling_group_id
id
The ID of existing scaling rule.

aliases: rule_id
name
The name of scaling rule.
It must contain 2-40 English or Chinese characters, and start with a number, a letter in upper or lower case or a Chinese character, and it can contain numbers, "_", "-" or ".".
Default to scaling rule Id.

aliases: rule_name
state
    Choices:
  • present ←
  • absent
present to create a scaling rule and absent to delete it.

Notes

Note

  • 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

- name: basic example
  hosts: localhost
  vars:
    alicloud_access_key: <your-alicloud-access-key-id>
    alicloud_secret_key: <your-alicloud-access-secret-key>
    alicloud_region: cn-beijing
    cooldown: 400
    group_id: asg-2zeimuvzeil1xfuor9ej
    name: ess-rule-foo
    adjustment_type: QuantityChangeInCapacity
    adjustment_value: 3

  tasks:
    - name: launch scaling rule
      ali_ess_rule:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        group_id: '{{ essgroup.id }}'
        adjustment_type: '{{adjustment_type}}'
        adjustment_value: '{{adjustment_value}}'
        cooldown: '{{cooldown}}'
        name: '{{name}}'

    - name: delete specified scaling rule
      ali_ess_rule:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        name: '{{ name }}'
        state: absent

Return Values

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

Key Returned Description
group_id
str
expect absent
ID of the scaling group of a scaling rule.

Sample:
asg-2zeimuvzeil1xfuor9ej
id
str
expect absent
Scaling Rule ID.

Sample:
asr-2zefe4bi0jpctd6z726p
name
str
expect absent
Scaling Rule name.

Sample:
ess-rule-foo
rule
dict
expect absent
The details of a scaling rule.

Sample:
{'adjustment_value': 3, 'cooldown': 400, 'name': 'from-ansible-roles-test_ess', 'ari': 'ari:acs:ess:cn-beijing:1204663572767468:scalingrule/asr-2zefe4bi0jpctd6z726p', 'adjustment_type': 'QuantityChangeInCapacity', 'group_id': 'asg-2zegiwc8m3ccxj0y1rbq', 'id': 'asr-2zefe4bi0jpctd6z726p'}


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.