| Removed in Ansible: | |
|---|---|
| version: 1.5.0 | |
| Why: | Alibaba Cloud module name prefix “ali” will be more concise. |
| Alternative: | Use ali_instance_facts 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
aliases: zone_id, zone |
|
| instance_ids |
A list of ECS instance ids.
aliases: ids |
|
| instance_names |
A list of ECS instance names.
aliases: names |
|
| instance_tags |
A hash/dictionaries of instance tags.
{"key":"value"}aliases: tags |
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# Fetch instances details according to setting different filters
- name: fetch instances details example
hosts: localhost
vars:
alicloud_access_key: <your-alicloud-access-key>
alicloud_secret_key: <your-alicloud-secret-key>
alicloud_region: cn-beijing
alicloud_zone: cn-beijing-a
tasks:
- name: Find all instances in the specified region
alicloud_instance_facts:
register: all_instances
- name: Find all instances based on the specified ids
alicloud_instance_facts:
instance_ids:
- "i-35b333d9"
- "i-ddav43kd"
register: instances_by_ids
- name: Find all instances based on the specified names/name-prefixes
alicloud_instance_facts:
instance_names:
- "ecs_instance-1"
- "ecs_instance_2"
register: instances_by_ids
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
|
instance_ids
list
|
when success |
List all instances's id after operating ecs instance.
Sample:
['i-2ze9zfjdhtasdrfbgay1']
|
|
instances
list
|
when success |
Details about the ecs instances that were created.
Sample:
[{'status': 'running', 'region_id': 'cn-beijing', 'block_device_mapping': {'d-2ze9mho1vp79mctdoro0': {'status': 'in_use', 'delete_on_termination': True, 'volume_id': 'd-2ze9mho1vp79mctdoro0'}}, 'key_name': 'test', 'public_ip': '47.94.45.175', 'image_id': 'ubuntu1404_64_40G_cloudinit_20160727.raw', 'private_ip': '10.31.153.209', 'vpc_attributes': {'nat_ip_address': '', 'private_ip_address': {'ip_address': []}, 'vswitch_id': '', 'vpc_id': ''}, 'eip': {'ip_address': '', 'internet_charge_type': '', 'allocation_id': ''}, 'group_ids': {'security_group_id': ['sg-2zegcq33l0yz9sknp08o']}, 'zone_id': 'cn-beijing-a', 'io_optimized': True, 'tags': {'create_test': '0.01'}, 'launch_time': '2017-05-23T00:56Z', 'id': 'i-2ze9zfjdhtasdrfbgay1', 'instance_name': 'test-instance', 'instance_type': 'ecs.n1.small', 'host_name': 'myhost'}]
|
|
total
int
|
when success |
The number of all instances after operating ecs instance.
Sample:
1
|
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.