- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# cloudscale_volume – Manages volumes on the cloudscale.ch IaaS service

New in version 2.8.

- Synopsis

- Parameters

- Notes

- Examples

- Return Values

- Status

## Synopsis

- Create, attach/detach, update and delete volumes on the cloudscale.ch IaaS service.

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
api_timeout - | Default: 30 | Timeout in seconds for calls to the cloudscale.ch API.
api_token - |  | cloudscale.ch API token. This can also be passed in the `CLOUDSCALE_API_TOKEN` environment variable.
name string |  | Name of the volume. Either name or UUID must be present to change an existing volume.
server_uuids list |  | UUIDs of the servers this volume is attached to. Set this to `[]` to detach the volume. Currently a volume can only be attached to a single server. aliases: server_uuid
size_gb integer |  | Size of the volume in GB.
state string | Choices: present ← absent | State of the volume.
tags dictionary added in 2.9 |  | Tags associated with the volume. Set this to `{}` to clear any tags.
type string | Choices: ssd bulk | Type of the volume. Cannot be changed after creating the volume. Defaults to `ssd` on volume creation.
uuid string |  | UUID of the volume. Either name or UUID must be present to change an existing volume.

## Notes

Note

- To create a new volume at least the name and size_gb options are required.

- A volume can be created and attached to a server in the same task.

- Instead of the api_token parameter the `CLOUDSCALE_API_TOKEN` environment variable can be used.

- All operations are performed using the cloudscale.ch public API v1.

- For details consult the full API documentation: https://www.cloudscale.ch/en/api/v1.

- A valid API token is required for all operations. You can create as many tokens as you like using the cloudscale.ch control panel at https://control.cloudscale.ch.

## Examples

    # Create a new SSD volume
    - name: Create an SSD volume
      cloudscale_volume:
        name: my_ssd_volume
        size_gb: 50
        api_token: xxxxxx
      register: my_ssd_volume

    # Attach an existing volume to a server
    - name: Attach volume to server
      cloudscale_volume:
        uuid: my_ssd_volume.uuid
        server_uuids:
          - ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
        api_token: xxxxxx

    # Create and attach a volume to a server
    - name: Create and attach volume to server
      cloudscale_volume:
        name: my_ssd_volume
        size_gb: 50
        server_uuids:
          - ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
        api_token: xxxxxx

    # Detach volume from server
    - name: Detach volume from server
      cloudscale_volume:
        uuid: my_ssd_volume.uuid
        server_uuids: []
        api_token: xxxxxx

    # Delete a volume
    - name: Delete volume
      cloudscale_volume:
        name: my_ssd_volume
        state: absent
        api_token: xxxxxx

## Return Values

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

Key | Returned | Description
--- | --- | ---
href string | state == present | The API URL to get details about this volume. Sample: https://api.cloudscale.ch/v1/volumes/2db69ba3-1864-4608-853a-0771b6885a3a
name string | state == present | The display name of the volume. Sample: my_ssd_volume
server_uuids list | state == present | The UUIDs of the servers this volume is attached to. Sample: ['47cec963-fcd2-482f-bdb6-24461b2d47b1']
size_gb string | state == present | The size of the volume in GB. Sample: 50
state string | success | The current status of the volume. Sample: present
tags dictionary added in 2.9 | state == present | Tags associated with the volume. Sample: {'project': 'my project'}
type string | state == present | The type of the volume. Sample: bulk
uuid string | state == present | The unique identifier for this volume. Sample: 2db69ba3-1864-4608-853a-0771b6885a3a

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]

- This module is maintained by the Ansible Community. [community]

### Authors

- Gaudenz Steinlin (@gaudenz)

- René Moser (@resmo)

Hint

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