W3cubDocs

/Ansible

cs_volume - Manages volumes on Apache CloudStack based clouds.

New in version 2.1.

Synopsis

Create, destroy, attach, detach volumes.

Requirements (on host that executes module)

  • python >= 2.6
  • cs >= 0.6.10

Options

parameter required default choices comments
account
no
Account the volume is related to.
api_http_method
no get
  • get
  • post
HTTP method used.
api_key
no
API key of the CloudStack API.
api_region
no cloudstack
Name of the ini section in the cloustack.ini file.
api_secret
no
Secret key of the CloudStack API.
api_timeout
no 10
HTTP timeout.
api_url
no
URL of the CloudStack API e.g. https://cloud.example.com/client/api.
custom_id
no
Custom id to the resource.
Allowed to Root Admins only.
disk_offering
no
Name of the disk offering to be used.
Required one of disk_offering, snapshot if volume is not already state=present.
display_volume
no True
Whether to display the volume to the end user or not.
Allowed to Root Admins only.
domain
no
Name of the domain the volume to be deployed in.
force
no
Force removal of volume even it is attached to a VM.
Considered on state=absnet only.
max_iops
no
Max iops
min_iops
no
Min iops
name
yes
Name of the volume.
name can only contain ASCII letters.
poll_async
no True
Poll async jobs until job has finished.
project
no
Name of the project the volume to be deployed in.
shrink_ok
no
Whether to allow to shrink the volume.
size
no
Size of disk in GB
snapshot
no
The snapshot name for the disk volume.
Required one of disk_offering, snapshot if volume is not already state=present.
state
no present
  • present
  • absent
  • attached
  • detached
State of the volume.
vm
no
Name of the virtual machine to attach the volume to.
zone
no
Name of the zone in which the volume should be deployed.
If not set, default zone is used.

Examples

# Create volume within project, zone with specified storage options
- local_action:
    module: cs_volume
    name: web-vm-1-volume
    project: Integration
    zone: ch-zrh-ix-01
    disk_offering: PerfPlus Storage
    size: 20

# Create/attach volume to instance
- local_action:
    module: cs_volume
    name: web-vm-1-volume
    disk_offering: PerfPlus Storage
    size: 20
    vm: web-vm-1
    state: attached

# Detach volume
- local_action:
    module: cs_volume
    name: web-vm-1-volume
    state: detached

# Remove volume
- local_action:
    module: cs_volume
    name: web-vm-1-volume
    state: absent

Return Values

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

name description returned type sample
domain Domain the volume belongs to success string example domain
group Group the volume belongs to success string web
name Name of the volume. success string web-volume-01
zone Name of zone the volume is in. success string ch-gva-2
created Date of the volume was created. success string 2014-12-01T14:57:57+0100
attached Date of the volume was attached. success string 2014-12-01T14:57:57+0100
vm Name of the vm the volume is attached to (not returned when detached) success string web-01
project Project the volume belongs to success string Production
state State of the volume success string Attached
display_name Display name of the volume. success string web-volume-01
size Size of disk volume. success string 20
type Disk volume type. success string DATADISK
id ID of the volume. success string None
device_id Id of the device on user vm the volume is attached to (not returned when detached) success string 1

Notes

Note

Ansible uses the cs library’s configuration method if credentials are not provided by the arguments api_url, api_key, api_secret. Configuration is read from several locations, in the following order. - The CLOUDSTACK_ENDPOINT, CLOUDSTACK_KEY, CLOUDSTACK_SECRET and CLOUDSTACK_METHOD. CLOUDSTACK_TIMEOUT environment variables. - A CLOUDSTACK_CONFIG environment variable pointing to an .ini file, - A cloudstack.ini file in the current working directory. - A .cloudstack.ini file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in cloudstack.ini. Use the argument api_region to select the section name, default section is cloudstack. See https://github.com/exoscale/cs for more information.

Note

A detailed guide about cloudstack modules can be found on http://docs.ansible.com/ansible/guide_cloudstack.html

Note

This module supports check mode.

This is an Extras Module

For more information on what this means please read Extras Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/cs_volume_module.html