Documentation

ali_disk_facts - Gather facts on disks of Alibaba Cloud ECS.

New in version 1.5.0.

Synopsis

  • This module fetches data from the Open API in Alicloud. The module must be called from within the ECS disk itself.

Requirements

The below requirements are needed on the host that executes this module.

  • footmark >= 1.1.16
  • python >= 2.6

Parameters

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 disk

aliases: zone_id, zone
disk_ids
A list of ECS disk ids.

aliases: ids
disk_names
A list of ECS disk names.

aliases: names

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 or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKEN
  • ALICLOUD_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

Examples

# Fetch disk details according to setting different filters
- name: fetch disk 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 disks in the specified region
      ali_disk_facts:
        alicloud_zone: "{{ alicloud_zone }}"
        alicloud_region: "{{ alicloud_region }}"
      register: all_disks
    - name: Find all disks based on the specified ids
      ali_disk_facts:
        alicloud_zone: "{{ alicloud_zone }}"
        alicloud_region: "{{ alicloud_region }}"
        disk_ids:
          - "d-2ze8ohezcyvm4omrabud"
          - "d-2zeakwizkdjdu4q4lfco"
      register: disks_by_ids
    - name: Find all disks based on the specified names/name-prefixes
      ali_disk_facts:
        alicloud_zone: "{{ alicloud_zone }}"
        alicloud_region: "{{ alicloud_region }}"
        disk_ids:
          - "d-2ze8ohezcyvm4omrabud"
          - "d-2zeakwizkdjdu4q4lfco"
        disk_names:
          - "test1"
      register: disks_by_names

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
disk_ids
list
when success
List all disk's id after operating ecs disk.

Sample:
['d-2ze8ohezcyvm4omrabud', 'd-2zeakwizkdjdu4q4lfco']
disks
list
when success
Details about the ecs disks that were created.

Sample:
[{'status': 'in_use', 'enable_auto_snapshot': True, 'region_id': 'cn-beijing', 'name': 'test1', 'operation_locks': {'operation_lock': []}, 'encrypted': False, 'snapshop_id': '', 'creation_time': '2017-08-15T06:47:45Z', 'image_id': 'ubuntu_140405_32_40G_cloudinit_20161115.vhd', 'device': '/dev/xvda', 'product_code': '', 'id': 'd-2ze8ohezcyvm4omrabud', 'size': 40, 'category': 'cloud_efficiency', 'disk_charge_type': 'PostPaid', 'zone_id': 'cn-beijing-a', 'type': 'system', 'description': 'helloworld', 'detached_time': '', 'attached_time': '2017-08-15T06:47:55Z', 'instance_id': 'i-2zegc3s8ihxq2pcysekk', 'portable': False, 'delete_auto_snapshot': False, 'delete_with_instance': True}, {'status': 'in_use', 'enable_auto_snapshot': True, 'region_id': 'cn-beijing', 'name': 'test2', 'operation_locks': {'operation_lock': []}, 'encrypted': False, 'snapshop_id': '', 'creation_time': '2017-08-13T06:57:30Z', 'image_id': 'ubuntu_140405_64_40G_cloudinit_20161115.vhd', 'device': '/dev/xvda', 'product_code': '', 'id': 'd-2zeakwizkdjdu4q4lfco', 'size': 40, 'category': 'cloud_efficiency', 'disk_charge_type': 'PostPaid', 'zone_id': 'cn-beijing-a', 'type': 'system', 'description': '', 'detached_time': '', 'attached_time': '2017-08-13T06:57:37Z', 'instance_id': 'i-2zeenj8meljkoi85lz3c', 'portable': False, 'delete_auto_snapshot': False, 'delete_with_instance': True}]
total
int
when success
The number of all disks after operating ecs disk.

Sample:
2


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • He Guimin (@xiaozhu36)

Hint

If you notice any issues in this documentation you can edit this document to improve it.