damex.incus.incus_storage_volume module – Ensure Incus storage volume

Note

This module is part of the damex.incus collection (version 1.8.9).

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 damex.incus.

To use it in a playbook, specify: damex.incus.incus_storage_volume.

Synopsis

  • Create, update, and delete Incus custom storage volumes via the Incus REST API.

  • Storage volumes are project-scoped resources within a storage pool.

  • The content type is set on creation and cannot be changed afterwards.

Parameters

Parameter

Comments

client_cert

path

Path to the client certificate for remote authentication.

Requires url and client_key. Mutually exclusive with token.

client_key

path

Path to the client key for remote authentication.

Requires url and client_cert.

config

dictionary

Storage volume configuration key-value pairs.

Boolean values are converted to lowercase strings.

Default: {}

block.filesystem

string

Filesystem type for block volumes.

block.mount_options

string

Mount options for block volumes.

size

string

Size of the storage volume.

snapshots.expiry

string

Automatic expiry time for snapshots.

snapshots.pattern

string

Pongo2 template for snapshot names.

snapshots.schedule

string

Cron expression for automatic snapshots.

zfs.block_mode

boolean

Whether to use a ZFS volume as a block device.

Choices:

  • false

  • true

zfs.blocksize

string

Block size for the ZFS volume.

zfs.delegate

boolean

Whether to delegate ZFS dataset to the instance.

Choices:

  • false

  • true

zfs.remove_snapshots

boolean

Whether to remove snapshots on volume removal.

Choices:

  • false

  • true

content_type

string

Content type of the storage volume.

Only used when creating a new volume.

Ignored on update — content type cannot be changed after creation.

Choices:

  • "filesystem" ← (default)

  • "block"

description

string

Storage volume description.

Default: ""

name

string / required

Name of the storage volume.

pool

string / required

Name of the storage pool containing the volume.

project

string

Incus project to query.

Default: "default"

server_cert

path

Path to the server certificate for remote verification.

Requires url.

socket_path

string

Path to the Incus Unix socket for local connections.

Default: "/var/lib/incus/unix.socket"

state

string

Desired state of the storage volume.

Choices:

  • "present" ← (default)

  • "absent"

target

string

Cluster member to create the storage volume on.

token

string

Token for remote authentication.

Requires url. Mutually exclusive with client_cert.

url

string

URL of the remote Incus server (e.g. https://host:8443).

If specified, connects via HTTPS instead of Unix socket.

validate_certs

boolean

Whether to validate the server TLS certificate.

Choices:

  • false

  • true ← (default)

wait

boolean

Whether to wait for async operations to complete before returning.

Set to false for fire-and-forget behaviour.

Choices:

  • false

  • true ← (default)

Examples

- name: Ensure filesystem storage volume
  damex.incus.incus_storage_volume:
    pool: default
    name: data

- name: Ensure block storage volume with size
  damex.incus.incus_storage_volume:
    pool: zfs
    name: disk1
    content_type: block
    config:
      size: 50GiB

- name: Ensure storage volume with snapshots
  damex.incus.incus_storage_volume:
    pool: default
    name: backups
    config:
      snapshots.schedule: "@daily"
      snapshots.expiry: 7d

- name: Ensure storage volume in project
  damex.incus.incus_storage_volume:
    pool: default
    name: data
    project: myproject

- name: Ensure storage volume on cluster member
  damex.incus.incus_storage_volume:
    pool: local
    name: data
    target: node1

- name: Ensure storage volume is absent
  damex.incus.incus_storage_volume:
    pool: default
    name: data
    state: absent

Authors

  • Roman Kuzmitskii (@damex)