| Removed in Ansible: | |
|---|---|
| version: 1.5.0 | |
| Why: | Alibaba Cloud module name prefix “ali” will be more concise. |
| Alternative: | Use ali_disk 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
required |
Aliyun availability zone ID which to launch the disk
aliases: zone_id, zone |
|
|
delete_with_instance
bool |
|
When set to true, the disk will be released along with terminating ECS instance. When mark instance's attribution 'OperationLocks' as "LockReason":"security", its value will be ignored and disk will be released along with terminating ECS instance.
aliases: delete_on_termination |
| description |
The description of ECS disk, which is a string of 2 to 256 characters. It cannot begin with http:// or https://.
aliases: disk_description |
|
| disk_category |
|
The category to apply to the disk.
aliases: volume_type, disk_type |
|
disk_id
required |
Disk ID is used to attach an existing disk (required instance_id), detach or remove an existing disk.
aliases: vol_id, id |
|
| disk_name |
The name of ECS disk, which is a string of 2 to 128 Chinese or English characters. It must begin with an uppercase/lowercase letter or a Chinese character and can contain numerals, ".", "_", or "-". It cannot begin with http:// or https://.
aliases: name |
|
| disk_tags |
A list of hash/dictionaries of instance tags, ['{"tag_key":"value", "tag_value":"value"}'], tag_key must be not null when tag_value isn't null.
aliases: tags |
|
| instance_id |
Ecs instance ID is used to attach the disk. The specified instance and disk must be in the same zone. If it is null or not be specified, the attached disk will be detach from instance.
aliases: instance |
|
| size |
Size of disk (in GB) to create. 'cloud' valid value is 5~2000; 'cloud_efficiency' or 'cloud_ssd' valid value is 20~32768.
aliases: volume_size, disk_size |
|
| snapshot_id |
Snapshot ID on which to base the data disk. If this parameter is specified, the value of 'size' will be ignored. The actual created disk size is the specified snapshot's size.
aliases: snapshot |
|
| state |
present
|
The state of operating ecs disk.
|
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#
# Provisioning new disk
#
# Basic provisioning example create a disk
- name: create disk
hosts: localhost
connection: local
vars:
alicloud_access_key: xxxxxxxxxx
alicloud_secret_key: xxxxxxxxxx
alicloud_region: cn-beijing
alicloud_zone: cn-beijing-b
size: 20
state: present
tasks:
- name: create disk
alicloud_disk:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
alicloud_zone: '{{ alicloud_zone }}'
size: '{{ size }}'
state: '{{ state }}'
register: result
- debug: var=result
# Advanced example with tagging and snapshot
- name: create disk
hosts: localhost
connection: local
vars:
alicloud_access_key: xxxxxxxxxx
alicloud_secret_key: xxxxxxxxxx
alicloud_region: cn-hongkong
alicloud_zone: cn-hongkong-b
disk_name: disk_1
description: data disk_1
size: 20
snapshot_id: xxxxxxxxxx
disk_category: cloud_ssd
state: present
tasks:
- name: create disk
alicloud_disk:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
alicloud_zone: '{{ alicloud_zone }}'
disk_name: '{{ disk_name }}'
description: '{{ description }}'
size: '{{ size }}'
snapshot_id: '{{ snapshot_id }}'
disk_category: '{{ disk_category }}'
state: '{{ state }}'
register: result
- debug: var=result
# Example to attach disk to an instance
- name: attach disk to instance
hosts: localhost
connection: local
vars:
state: present
alicloud_access_key: xxxxxxxxxx
alicloud_secret_key: xxxxxxxxxx
alicloud_region: us-west-1
instance_id: xxxxxxxxxx
disk_id: xxxxxxxxxx
delete_with_instance: no
tasks:
- name: Attach Disk to instance
alicloud_disk:
state: '{{ state }}'
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
instance_id: '{{ instance_id }}'
disk_id: '{{ disk_id }}'
delete_with_instance: '{{ delete_with_instance }}'
register: result
- debug: var=result
# Example to detach disk from instance
- name: detach disk
hosts: localhost
connection: local
vars:
alicloud_access_key: xxxxxxxxxx
alicloud_secret_key: xxxxxxxxxx
alicloud_region: us-west-1
disk_id: xxxxxxxxxx
state: present
tasks:
- name: detach disk
alicloud_disk:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
id: '{{ disk_id }}'
state: '{{ state }}'
register: result
- debug: var=result
# Example to delete disk
- name: detach disk
hosts: localhost
connection: local
vars:
alicloud_access_key: xxxxxxxxxx
alicloud_secret_key: xxxxxxxxxx
alicloud_region: us-west-1
disk_id: xxxxxxxxxx
state: absent
tasks:
- name: detach disk
alicloud_disk:
alicloud_access_key: '{{ alicloud_access_key }}'
alicloud_secret_key: '{{ alicloud_secret_key }}'
alicloud_region: '{{ alicloud_region }}'
disk_id: '{{ disk_id }}'
state: '{{ state }}'
register: result
- debug: var=result
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
|
device
string
|
except on delete |
device name of attached disk
Sample:
/def/xdva
|
|
disk
dict
|
except on delete |
Details about the ecs disk that was created.
Sample:
{'category': 'cloud_efficiency', 'status': 'available', 'region_id': 'cn-beijing', 'description': 'travis-ansible-instance', 'launch_time': '2017-06-19T03:19:30Z', 'instance_id': '', 'device': '', 'size': 40, 'type': 'data', 'id': 'd-2ze9yw0a1sw9neyx8t24', 'disk_name': 'travis-ansible-instance', 'zone_id': 'cn-beijing-a'}
|
|
disk_category
string
|
except on delete |
the category of disk
Sample:
cloud
|
|
disk_id
string
|
when success |
the id of disk
Sample:
d-2zecn395ktww53aylfw6
|
|
disk_status
string
|
except on delete |
the current status of disk
Sample:
available
|
|
instance_id
string
|
on attach |
the instance id which attached disk
Sample:
i-i2rnfnenfnds
|
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.