| Removed in Ansible: | |
|---|---|
| version: 1.5.0 | |
| Why: | Alibaba Cloud module name prefix “ali” will be more concise. |
| Alternative: | Use ali_instance instead. |
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 |
|
| alicloud_zone |
Aliyun availability zone ID in which to launch the instance. If it is not specified, it will be allocated by system automatically.
aliases: zone_id, zone |
|
|
allocate_public_ip
bool |
|
Whether allocate a public ip for the new instance.
aliases: assign_public_ip |
|
auto_renew
bool |
|
Whether automate renew the charge of the instance.
|
| auto_renew_period |
|
The duration of the automatic renew the charge of the instance. Required when
auto_renew=True. |
| count |
Default: 1
|
The number of the new instance. An integer value which indicates how many instances that match count_tag should be running. Instances are either created or terminated based on this value.
|
| count_tag |
count determines how many instances based on a specific tag criteria should be present. This can be expressed in multiple ways and is shown in the EXAMPLES section. The specified count_tag must already exist or be passed in as the instance_tags option. If it is not specified, it will be replaced by instance_name.
|
|
| description |
The description of ECS instance, which is a string of 2 to 256 characters. It cannot begin with http:// or https://.
|
|
|
force
bool |
|
Whether the current operation needs to be execute forcibly.
|
| group_id |
Security Group id used to launch instance or join/remove existing instances to/from the specified Security Group.
aliases: security_group_id |
|
| host_name |
Instance host name.
|
|
| image_id |
Image ID used to launch instances. Required when
state=present and creating new ECS instances.aliases: image |
|
| instance_charge_type |
|
The charge type of the instance.
|
| instance_ids |
A list of instance ids. It is required when need to operate existing instances. If it is specified, count will lose efficacy.
|
|
| instance_name |
The name of ECS instance, which is a string of 2 to 128 Chinese or English characters. It must begin with an uppercase/lowercase letter or a Chinese character and can contain numerals, ".", "_" or "-". It cannot begin with http:// or https://.
aliases: name |
|
| instance_tags |
A hash/dictionaries of instance tags, to add to the new instance or for starting/stopping instance by tag.
{"key":"value"}aliases: tags |
|
| instance_type |
Instance type used to launch instances. Required when
state=present and creating new ECS instances.aliases: type |
|
| internet_charge_type |
|
Internet charge type of ECS instance.
|
| key_name |
The name of key pair which is used to access ECS instance in SSH.
aliases: keypair |
|
| max_bandwidth_in |
Default: 200
|
Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second).
|
| max_bandwidth_out |
Default: 0
|
Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second).
|
| password |
The password to login instance. After rebooting instances, the modified password would be take effect.
|
|
| period |
1
|
The charge duration of the instance. Required when
instance_charge_type=PrePaid. |
| sg_action |
|
The action of operating security group.
|
| state |
|
The state of the instance after operating.
|
| system_disk_category |
|
Category of the system disk.
|
| system_disk_description |
Description of the system disk.
|
|
| system_disk_name |
Name of the system disk.
|
|
| system_disk_size |
40
|
Size of the system disk, in GB
|
| user_data |
User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance. It only will take effect when launching the new ECS instances.
|
|
| vswitch_id |
The subnet ID in which to launch the instances (VPC).
aliases: subnet_id |
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# basic provisioning example vpc network
- name: basic provisioning example
hosts: localhost
vars:
alicloud_access_key: <your-alicloud-access-key-id>
alicloud_secret_key: <your-alicloud-access-secret-key>
alicloud_region: cn-beijing
image: ubuntu1404_64_40G_cloudinit_20160727.raw
instance_type: ecs.n4.small
vswitch_id: vsw-abcd1234
assign_public_ip: True
max_bandwidth_out: 10
host_name: myhost
password: mypassword
system_disk_category: cloud_efficiency
system_disk_size: 100
internet_charge_type: PayByBandwidth
group_id: sg-f2rwnfh23r
sg_action: join
instance_ids: ["i-abcd12346", "i-abcd12345"]
force: True
tasks:
- name: launch ECS instance in VPC network
alicloud_instance:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
image: '{{ image }}'
system_disk_category: '{{ system_disk_category }}'
system_disk_size: '{{ system_disk_size }}'
instance_type: '{{ instance_type }}'
vswitch_id: '{{ vswitch_id }}'
assign_public_ip: '{{ assign_public_ip }}'
internet_charge_type: '{{ internet_charge_type }}'
max_bandwidth_out: '{{ max_bandwidth_out }}'
instance_tags:
Name: created_one
host_name: '{{ host_name }}'
password: '{{ password }}'
- name: with count and count_tag to create a number of instances
alicloud_instance:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
image: '{{ image }}'
system_disk_category: '{{ system_disk_category }}'
system_disk_size: '{{ system_disk_size }}'
instance_type: '{{ instance_type }}'
assign_public_ip: '{{ assign_public_ip }}'
group_id: '{{ group_id }}'
internet_charge_type: '{{ internet_charge_type }}'
max_bandwidth_out: '{{ max_bandwidth_out }}'
instance_tags:
Name: created_one
Version: 0.1
count: 2
count_tag:
Name: created_one
host_name: '{{ host_name }}'
password: '{{ password }}'
- name: start instance
alicloud_instance:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
instance_ids: '{{ instance_ids }}'
state: 'running'
- name: reboot instance forcibly
ecs:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
instance_ids: '{{ instance_ids }}'
state: 'restarted'
force: '{{ force }}'
- name: Add instances to an security group
ecs:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
instance_ids: '{{ instance_ids }}'
group_id: '{{ group_id }}'
sg_action: '{{ sg_action }}'
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
|
instance_ids
list
|
expect absent |
List all instances's id after operating ecs instance.
Sample:
['i-35b333d9', 'i-ddavdaeb3']
|
|
instance_ips
list
|
expect absent |
List all instances's public ip address after operating ecs instance.
Sample:
['10.1.1.1', '10.1.1.2']
|
|
instance_names
list
|
expect absent |
List all instances's name after operating ecs instance.
Sample:
['MyInstane', 'MyInstane2']
|
|
total
int
|
expect absent |
The number of all instances after operating ecs instance.
Sample:
2
|
This module is flagged as deprecated and will be removed in version 1.5.0. For more information see DEPRECATED.
Hint
If you notice any issues in this documentation you can edit this document to improve it.