ansible / ansible.builtin / v2.9.27 / module / _ali_instance_facts Gather information on instances of Alibaba Cloud ECS. | "added in version" 2.8 of ansible.builtin" Authors: He Guimin (@xiaozhu36) preview | supported by communityansible.builtin._ali_instance_facts (v2.9.27) — module
pip
Install with pip install ansible==2.9.27
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 C(ali_instance_facts) before Ansible 2.9. The usage did not change.
# 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 availability_zone: cn-beijing-a tasks: - name: Find all instances in the specified region ali_instance_info: alicloud_access_key: '{{ alicloud_access_key }}' alicloud_secret_key: '{{ alicloud_secret_key }}' alicloud_region: '{{ alicloud_region }}' register: all_instances - name: Find all instances based on the specified ids ali_instance_info: alicloud_access_key: '{{ alicloud_access_key }}' alicloud_secret_key: '{{ alicloud_secret_key }}' alicloud_region: '{{ alicloud_region }}' instance_ids: - "i-35b333d9" - "i-ddav43kd" register: instances_by_ids - name: Find all instances based on the specified names/name-prefixes ali_instance_info: alicloud_access_key: '{{ alicloud_access_key }}' alicloud_secret_key: '{{ alicloud_secret_key }}' alicloud_region: '{{ alicloud_region }}' instance_names: - "ecs_instance-1" - "ecs_instance_2" register: instances_by_ids
profile: description: - This is the Alicloud profile name as set in the shared credentials file. It can also be sourced from the ALICLOUD_PROFILE environment variable. type: str instance_ids: aliases: - ids description: - A list of ECS instance ids. ecs_role_name: aliases: - role_name description: - 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 U(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. type: str instance_tags: aliases: - tags description: - A hash/dictionaries of instance tags. C({"key":"value"}) instance_names: aliases: - names description: - A list of ECS instance names. alicloud_region: aliases: - region - region_id description: - The Alibaba Cloud region to use. If not specified then the value of environment variable C(ALICLOUD_REGION), C(ALICLOUD_REGION_ID) will be used instead. required: true type: str availability_zone: aliases: - alicloud_zone description: - Aliyun availability zone ID in which to launch the instance alicloud_access_key: aliases: - access_key_id - access_key description: - Alibaba Cloud access key. If not set then the value of environment variable C(ALICLOUD_ACCESS_KEY), C(ALICLOUD_ACCESS_KEY_ID) will be used instead. type: str alicloud_secret_key: aliases: - secret_access_key - secret_key description: - Alibaba Cloud secret key. If not set then the value of environment variable C(ALICLOUD_SECRET_KEY), C(ALICLOUD_SECRET_ACCESS_KEY) will be used instead. type: str alicloud_assume_role: aliases: - assume_role description: - If provided with a role ARN, Ansible will attempt to assume this role using the supplied credentials. - The nested assume_role block supports I(alicloud_assume_role_arn), I(alicloud_assume_role_session_name), I(alicloud_assume_role_session_expiration) and I(alicloud_assume_role_policy) type: dict alicloud_security_token: aliases: - security_token description: - The Alibaba Cloud security token. If not specified then the value of environment variable C(ALICLOUD_SECURITY_TOKEN) will be used instead. type: str shared_credentials_file: description: - 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. type: str alicloud_assume_role_arn: aliases: - assume_role_arn description: - 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. type: str alicloud_assume_role_session_name: aliases: - assume_role_session_name description: - 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 type: str alicloud_assume_role_session_expiration: aliases: - assume_role_session_expiration description: - 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 type: int
ids: description: List of ECS instance IDs returned: always sample: - i-12345er - i-3245fs type: list instances: contains: availability_zone: description: The availability zone of the instance is in. returned: always sample: cn-beijing-a type: str block_device_mappings: contains: attach_time: description: The time stamp when the attachment initiated. returned: always sample: '2018-06-25T04:08:26Z' type: str delete_on_termination: description: Indicates whether the volume is deleted on instance termination. returned: always sample: true type: bool device_name: description: The device name exposed to the instance (for example, /dev/xvda). returned: always sample: /dev/xvda type: str status: description: The attachment state. returned: always sample: in_use type: str volume_id: description: The ID of the cloud disk. returned: always sample: d-2zei53pjsi117y6gf9t6 type: str description: Any block device mapping entries for the instance. returned: always type: complex cpu: description: The CPU core count of the instance. returned: always sample: 4 type: int creation_time: description: The time the instance was created. returned: always sample: 2018-06-25T04:08Z type: str description: description: The instance description. returned: always sample: my ansible instance type: str eip: contains: allocation_id: description: The ID of the EIP. returned: always sample: eip-12345 type: str internet_charge_type: description: The internet charge type of the EIP. returned: always sample: paybybandwidth type: str ip_address: description: EIP address. returned: always sample: 42.10.2.2 type: str description: The attribution of EIP associated with the instance. returned: always type: complex expired_time: description: The time the instance will expire. returned: always sample: 2099-12-31T15:59Z type: str gpu: contains: amount: description: The count of the GPU. returned: always sample: 0 type: int spec: description: The specification of the GPU. returned: always sample: '' type: str description: The attribution of instance GPU. returned: always type: complex host_name: description: The host name of the instance. returned: always sample: iZ2zewaoZ type: str id: description: Alias of instance_id. returned: always sample: i-abc12345 type: str image_id: description: The ID of the image used to launch the instance. returned: always sample: m-0011223344 type: str inner_ip_address: description: The inner IPv4 address of the classic instance. returned: always sample: 10.0.0.2 type: str instance_charge_type: description: The instance charge type. returned: always sample: PostPaid type: str instance_id: description: ECS instance resource ID. returned: always sample: i-abc12345 type: str instance_name: description: The name of the instance. returned: always sample: my-ecs type: str instance_type: description: The instance type of the running instance. returned: always sample: ecs.sn1ne.xlarge type: str internet_charge_type: description: The billing method of the network bandwidth. returned: always sample: PayByBandwidth type: str internet_max_bandwidth_in: description: Maximum incoming bandwidth from the internet network. returned: always sample: 200 type: int internet_max_bandwidth_out: description: Maximum incoming bandwidth from the internet network. returned: always sample: 20 type: int io_optimized: description: Indicates whether the instance is optimized for EBS I/O. returned: always sample: false type: bool memory: description: Memory size of the instance. returned: always sample: 8192 type: int network_interfaces: contains: mac_address: description: The MAC address. returned: always sample: 00:11:22:33:44:55 type: str network_interface_id: description: The ID of the network interface. returned: always sample: eni-01234567 type: str primary_ip_address: description: The primary IPv4 address of the network interface within the vswitch. returned: always sample: 10.0.0.1 type: str description: One or more network interfaces for the instance. returned: always type: complex osname: description: The operation system name of the instance owned. returned: always sample: CentOS type: str ostype: description: The operation system type of the instance owned. returned: always sample: linux type: str private_ip_address: description: The IPv4 address of the network interface within the subnet. returned: always sample: 10.0.0.1 type: str public_ip_address: description: The public IPv4 address assigned to the instance returned: always sample: 43.0.0.1 type: str resource_group_id: description: The id of the resource group to which the instance belongs. returned: always sample: my-ecs-group type: str security_groups: contains: group_id: description: The ID of the security group. returned: always sample: sg-0123456 type: str group_name: description: The name of the security group. returned: always sample: my-security-group type: str description: One or more security groups for the instance. returned: always type: list of complex status: description: The current status of the instance. returned: always sample: running type: str tags: description: Any tags assigned to the instance. returned: always sample: null type: dict vpc_id: description: The ID of the VPC the instance is in. returned: always sample: vpc-0011223344 type: dict vswitch_id: description: The ID of the vswitch in which the instance is running. returned: always sample: vsw-dew00abcdef type: str description: List of ECS instances returned: always type: complex