cloudscale_ch.cloud.volume_snapshot module – Manage volume snapshots on the cloudscale.ch IaaS service

Note

This module is part of the cloudscale_ch.cloud collection (version 2.5.2).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cloudscale_ch.cloud.

To use it in a playbook, specify: cloudscale_ch.cloud.volume_snapshot.

New in cloudscale_ch.cloud 2.5.0

Synopsis

  • Get, create, update, delete volume snapshots on the cloudscale.ch IaaS service.

Parameters

Parameter

Comments

api_timeout

integer

Timeout in seconds for calls to the cloudscale.ch API.

This can also be passed in the CLOUDSCALE_API_TIMEOUT environment variable.

Default: 45

api_token

string / required

cloudscale.ch API token.

This can also be passed in the CLOUDSCALE_API_TOKEN environment variable.

api_url

string

added in cloudscale_ch.cloud 1.3.0

cloudscale.ch API URL.

This can also be passed in the CLOUDSCALE_API_URL environment variable.

Default: "https://api.cloudscale.ch/v1"

name

string

Name of the volume snapshot. Either name or uuid are required.

source_volume

string

UUID of the volume this snapshot belongs to. If name and source_volume are present, a new volume snapshot is created. This parameter has no effect on existing volume snapshots (uuid option is present).

state

string

State of the volume snapshot.

Choices:

  • "present" ← (default)

  • "absent"

tags

dictionary

Tags assigned to the volume snapshot. Set this to {} to clear any tags.

uuid

string

UUID of the volume snapshot.

Notes

Note

  • If uuid option is provided, it takes precedence over name for volume snapshot selection. This allows to update the volume snapshot’s name.

  • If no uuid option is provided, name is used for volume snapshot selection. If more than one volume snapshot with this name exists, execution is aborted.

  • To revert a snapshot use the volume module.

  • 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 volume snapshot for a volume
- name: Create a volume snapshot
  cloudscale_ch.cloud.volume_snapshot:
    name: 'pre-dist-upgrade'
    source_volume: '2db69ba3-1864-4608-853a-0771b6885a3a'
    tags: {}
    api_token: xxxxx

# Get a volume snapshot by name
- name: Get facts of a volume snapshot
  cloudscale_ch.cloud.volume_snapshot:
    name: 'pre-dist-upgrade'
    api_token: xxxxx

# Delete a volume snapshot
- name: Delete a volume snapshot
  cloudscale_ch.cloud.volume_snapshot:
    uuid: '351d461c-2333-455f-b788-db11bf0b4aa2'
    state: absent

Return Values

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

Key

Description

created_at

string

The creation date and time of the resource.

Returned: state == present

Sample: "2025-04-10T11:05:45.777073Z"

href

string

The API URL to get details about this volume snapshot.

Returned: state == present

Sample: "https://api.cloudscale.ch/v1/volume-snapshots/e504dc99-ff01-4e89-ad89-7df080f97b4b"

name

string

The display name of the volume snapshot.

Returned: state == present

Sample: "my_ssd_volume_snapshot"

size_gb

string

The size of the volume in GB.

Returned: state == present

Sample: "50"

source_volume

dictionary

The source volume this volume snapshot belongs to.

Returned: state == present

Sample: {"source_volume": {"href": "https://api.cloudscale.ch/v1/volumes/0952b1ca-3657-4901-b4c8-669796ec55e6", "name": "my_ssd_volume", "uuid": "0952b1ca-3657-4901-b4c8-669796ec55e6"}}

state

string

The current status of the volume.

Returned: success

Sample: "present"

status

string

The current status of the volume snapshot.

Returned: success

Sample: "available"

tags

dictionary

Tags associated with the volume.

Returned: state == present

Sample: {"project": "my project"}

uuid

string

The unique identifier for this volume snapshot.

Returned: state == present

Sample: "e504dc99-ff01-4e89-ad89-7df080f97b4b"

Authors

  • Ciril Troxler (@ctx)