community.general.ali_instance_info – Gather information on instances of Alibaba Cloud ECS.¶
Note
This plugin is part of the community.general collection (version 1.3.6).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.ali_instance_info
.
Synopsis¶
This module fetches data from the Open API in Alicloud. The module must be called from within the ECS instance itself.
This module was called
ali_instance_facts
before Ansible 2.9. The usage did not change.
Requirements¶
The below requirements are needed on the host that executes this module.
footmark >= 1.13.0
python >= 3.6
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
alicloud_access_key
string
|
Alibaba 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_assume_role
dictionary
|
If provided with a role ARN, Ansible will attempt to assume this role using the supplied credentials.
The nested assume_role block supports alicloud_assume_role_arn, alicloud_assume_role_session_name, alicloud_assume_role_session_expiration and alicloud_assume_role_policy
aliases: assume_role |
|
alicloud_assume_role_arn
string
|
The Alibaba Cloud role_arn. The ARN of the role to assume. If ARN is set to an empty string, it does not perform role switching. It supports environment variable ALICLOUD_ASSUME_ROLE_ARN. ansible will execute with provided credentials.
aliases: assume_role_arn |
|
alicloud_assume_role_session_expiration
integer
|
The Alibaba Cloud session_expiration. The time after which the established session for assuming role expires. Valid value range 900-3600 seconds. Default to 3600 (in this case Alicloud use own default value). It supports environment variable ALICLOUD_ASSUME_ROLE_SESSION_EXPIRATION
aliases: assume_role_session_expiration |
|
alicloud_assume_role_session_name
string
|
The Alibaba Cloud session_name. The session name to use when assuming the role. If omitted, 'ansible' is passed to the AssumeRole call as session name. It supports environment variable ALICLOUD_ASSUME_ROLE_SESSION_NAME
aliases: assume_role_session_name |
|
alicloud_region
string
/ required
|
The Alibaba 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
string
|
Alibaba 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
string
|
The Alibaba Cloud security token. If not specified then the value of environment variable
ALICLOUD_SECURITY_TOKEN will be used instead.aliases: security_token |
|
availability_zone
string
|
(Deprecated) Aliyun availability zone ID in which to launch the instance. Please use filter item 'zone_id' instead.
aliases: alicloud_zone |
|
ecs_role_name
string
|
The RAM Role Name attached on a ECS instance for API operations. You can retrieve this from the 'Access Control' section of the Alibaba Cloud console.
If you're running Ansible from an ECS instance with RAM Instance using RAM Role, Ansible will just access the metadata http://100.100.100.200/latest/meta-data/ram/security-credentials/<ecs_role_name> to obtain the STS credential. This is a preferred approach over any other when running in ECS as you can avoid hard coding credentials. Instead these are leased on-the-fly by Ansible which reduces the chance of leakage.
aliases: role_name |
|
filters
dictionary
added in 0.2.0 of community.general
|
A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be all of request parameters. See https://www.alibabacloud.com/help/doc-detail/25506.htm for parameter details. Filter keys can be same as request parameter name or be lower case and use underscore ("_") or dash ("-") to connect different words in one parameter. 'InstanceIds' should be a list and it will be appended to instance_ids automatically. 'Tag.n.Key' and 'Tag.n.Value' should be a dict and using tags instead.
|
|
instance_ids
list
/ elements=string
|
A list of ECS instance ids.
aliases: ids |
|
instance_names
list
/ elements=string
|
(Deprecated) A list of ECS instance names. Please use filter item 'instance_name' instead.
aliases: names |
|
name_prefix
string
added in 0.2.0 of community.general
|
Use a instance name prefix to filter ecs instances.
|
|
profile
string
|
This is the Alicloud profile name as set in the shared credentials file. It can also be sourced from the ALICLOUD_PROFILE environment variable.
|
|
shared_credentials_file
string
|
This is the path to the shared credentials file. It can also be sourced from the ALICLOUD_SHARED_CREDENTIALS_FILE environment variable.
If this is not set and a profile is specified, ~/.aliyun/config.json will be used.
|
|
tags
dictionary
|
A hash/dictionaries of instance tags.
{"key":"value"} aliases: instance_tags |
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
orALICLOUD_ACCESS_KEY_ID
,ALICLOUD_SECRET_KEY
orALICLOUD_SECRET_ACCESS_KEY
,ALICLOUD_REGION
orALICLOUD_REGION_ID
,ALICLOUD_SECURITY_TOKEN
,ALICLOUD_ECS_ROLE_NAME
,ALICLOUD_SHARED_CREDENTIALS_FILE
,ALICLOUD_PROFILE
,ALICLOUD_ASSUME_ROLE_ARN
,ALICLOUD_ASSUME_ROLE_SESSION_NAME
,ALICLOUD_ASSUME_ROLE_SESSION_EXPIRATION
,ALICLOUD_REGION
orALICLOUD_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¶
# Fetch instances details according to setting different filters
- name: Find all instances in the specified region
community.general.ali_instance_info:
register: all_instances
- name: Find all instances based on the specified ids
community.general.ali_instance_info:
instance_ids:
- "i-35b333d9"
- "i-ddav43kd"
register: instances_by_ids
- name: Find all instances based on the specified name_prefix
community.general.ali_instance_info:
name_prefix: "ecs_instance_"
register: instances_by_name_prefix
- name: Find instances based on tags
community.general.ali_instance_info:
tags:
Test: "add"
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
He Guimin (@xiaozhu36)