Documentation

cs_volume – Manages volumes on Apache CloudStack based clouds.

New in version 2.1.

Synopsis

  • Create, destroy, attach, detach volumes.

Requirements

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

  • python >= 2.6
  • cs >= 0.6.10

Parameters

Parameter Choices/Defaults Comments
account
-
Account the volume is related to.
api_http_method
-
    Choices:
  • get
  • post
HTTP method used to query the API endpoint.
If not given, the CLOUDSTACK_METHOD env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
Fallback value is get if not specified.
api_key
-
API key of the CloudStack API.
If not given, the CLOUDSTACK_KEY env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
api_region
-
Default:
cloudstack
Name of the ini section in the cloustack.ini file.
If not given, the CLOUDSTACK_REGION env variable is considered.
api_secret
-
Secret key of the CloudStack API.
If not set, the CLOUDSTACK_SECRET env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
api_timeout
-
HTTP timeout in seconds.
If not given, the CLOUDSTACK_TIMEOUT env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
Fallback value is 10 seconds if not specified.
api_url
-
URL of the CloudStack API e.g. https://cloud.example.com/client/api.
If not given, the CLOUDSTACK_ENDPOINT env variable is considered.
As the last option, the value is taken from the ini config file, also see the notes.
custom_id
-
Custom id to the resource.
Allowed to Root Admins only.
disk_offering
-
Name of the disk offering to be used.
Required one of disk_offering, snapshot if volume is not already state=present.
display_volume
-
Default:
yes
Whether to display the volume to the end user or not.
Allowed to Root Admins only.
domain
-
Name of the domain the volume to be deployed in.
force
-
Default:
no
Force removal of volume even it is attached to a VM.
Considered on state=absnet only.
max_iops
-
Max iops
min_iops
-
Min iops
name
- / required
Name of the volume.
name can only contain ASCII letters.
poll_async
-
Default:
yes
Poll async jobs until job has finished.
project
-
Name of the project the volume to be deployed in.
shrink_ok
-
Default:
no
Whether to allow to shrink the volume.
size
-
Size of disk in GB
snapshot
-
The snapshot name for the disk volume.
Required one of disk_offering, snapshot if volume is not already state=present.
state
-
    Choices:
  • present ←
  • absent
  • attached
  • detached
State of the volume.
tags
-
added in 2.4
List of tags. Tags are a list of dictionaries having keys key and value.
To delete all tags, set a empty list e.g. tags: [].

aliases: tag
vm
-
Name of the virtual machine to attach the volume to.
zone
-
Name of the zone in which the volume should be deployed.
If not set, default zone is used.

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.
  • A detailed guide about cloudstack modules can be found in the CloudStack Cloud Guide.
  • This module supports check mode.

Examples

- name: create volume within project and 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

- name: 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

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

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

Return Values

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

Key Returned Description
attached
string
success
Date of the volume was attached.

Sample:
2014-12-01T14:57:57+0100
created
string
success
Date of the volume was created.

Sample:
2014-12-01T14:57:57+0100
device_id
string
success
Id of the device on user vm the volume is attached to (not returned when detached)

Sample:
1
display_name
string
success
Display name of the volume.

Sample:
web-volume-01
domain
string
success
Domain the volume belongs to

Sample:
example domain
group
string
success
Group the volume belongs to

Sample:
web
id
string
success
ID of the volume.

name
string
success
Name of the volume.

Sample:
web-volume-01
project
string
success
Project the volume belongs to

Sample:
Production
size
string
success
Size of disk volume.

Sample:
20
state
string
success
State of the volume

Sample:
Attached
type
string
success
Disk volume type.

Sample:
DATADISK
vm
string
success
Name of the vm the volume is attached to (not returned when detached)

Sample:
web-01
zone
string
success
Name of zone the volume is in.

Sample:
ch-gva-2


Status

  • This module is guaranteed to have no backward incompatible interface changes going forward. [stableinterface]
  • This module is maintained by the Ansible Community. [community]

Authors

  • Jefferson Girão (@jeffersongirao)
  • René Moser (@resmo)

Hint

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