community.general.ali_instance_info module – Gather information on instances of Alibaba Cloud ECS
Note
This module is part of the community.general collection (version 8.6.8).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
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.
Aliases: cloud.alicloud.ali_instance_info
Requirements
The below requirements are needed on the host that executes this module.
Python >= 3.6
footmark >= 1.13.0
Parameters
Parameter |
Comments |
---|---|
Alibaba Cloud access key. If not set then the value of environment variable |
|
If provided with a role ARN, Ansible will attempt to assume this role using the supplied credentials. The nested assume_role block supports |
|
The Alibaba Cloud |
|
The Alibaba Cloud |
|
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 |
|
The Alibaba Cloud region to use. If not specified then the value of environment variable |
|
Alibaba Cloud secret key. If not set then the value of environment variable |
|
The Alibaba Cloud security token. If not specified then the value of environment variable |
|
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. |
|
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 ( |
|
Use a instance name prefix to filter ecs instances. |
|
This is the Alicloud profile name as set in the shared credentials file. It can also be sourced from the |
|
This is the path to the shared credentials file. It can also be sourced from the If this is not set and a profile is specified, |
|
A hash/dictionaries of instance tags. |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full added in community.general 3.3.0 This action does not modify state. |
Can run in |
|
Support: N/A This action does not modify state. |
Will return details on what has changed (or possibly needs changing in |
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:
Key |
Description |
---|---|
List of ECS instance IDs Returned: always Sample: |
|
List of ECS instances Returned: always |
|
The availability zone of the instance is in. Returned: always Sample: |
|
Any block device mapping entries for the instance. Returned: always |
|
The time stamp when the attachment initiated. Returned: always Sample: |
|
Indicates whether the volume is deleted on instance termination. Returned: always Sample: |
|
The device name exposed to the instance (for example, /dev/xvda). Returned: always Sample: |
|
The attachment state. Returned: always Sample: |
|
The ID of the cloud disk. Returned: always Sample: |
|
The CPU core count of the instance. Returned: always Sample: |
|
The time the instance was created. Returned: always Sample: |
|
The instance description. Returned: always Sample: |
|
The attribution of EIP associated with the instance. Returned: always |
|
The ID of the EIP. Returned: always Sample: |
|
The internet charge type of the EIP. Returned: always Sample: |
|
EIP address. Returned: always Sample: |
|
The time the instance will expire. Returned: always Sample: |
|
The attribution of instance GPU. Returned: always |
|
The count of the GPU. Returned: always Sample: |
|
The specification of the GPU. Returned: always Sample: |
|
The host name of the instance. Returned: always Sample: |
|
Alias of instance_id. Returned: always Sample: |
|
The ID of the image used to launch the instance. Returned: always Sample: |
|
The inner IPv4 address of the classic instance. Returned: always Sample: |
|
The instance charge type. Returned: always Sample: |
|
ECS instance resource ID. Returned: always Sample: |
|
The name of the instance. Returned: always Sample: |
|
The instance type of the running instance. Returned: always Sample: |
|
The instance type family of the instance belongs. Returned: always Sample: |
|
The billing method of the network bandwidth. Returned: always Sample: |
|
Maximum incoming bandwidth from the internet network. Returned: always Sample: |
|
Maximum incoming bandwidth from the internet network. Returned: always Sample: |
|
Indicates whether the instance is optimized for EBS I/O. Returned: always Sample: |
|
Memory size of the instance. Returned: always Sample: |
|
One or more network interfaces for the instance. Returned: always |
|
The MAC address. Returned: always Sample: |
|
The ID of the network interface. Returned: always Sample: |
|
The primary IPv4 address of the network interface within the vswitch. Returned: always Sample: |
|
The operation system name of the instance owned. Returned: always Sample: |
|
The operation system type of the instance owned. Returned: always Sample: |
|
The IPv4 address of the network interface within the subnet. Returned: always Sample: |
|
The public IPv4 address assigned to the instance or eip address Returned: always Sample: |
|
The id of the resource group to which the instance belongs. Returned: always Sample: |
|
One or more security groups for the instance. Returned: always |
|
The ID of the security group. Returned: always Sample: |
|
The name of the security group. Returned: always Sample: |
|
The current status of the instance. Returned: always Sample: |
|
Any tags assigned to the instance. Returned: always |
|
The ID of the VPC the instance is in. Returned: always Sample: |
|
The ID of the vswitch in which the instance is running. Returned: always Sample: |