community.general.lxd_storage_volume_info module – Retrieve information about LXD storage volumes

Note

This module is part of the community.general collection (version 12.2.0).

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 community.general.

To use it in a playbook, specify: community.general.lxd_storage_volume_info.

New in community.general 12.1.0

Synopsis

  • Retrieve information about LXD storage volumes in a specific storage pool.

  • This module returns details about all volumes or a specific volume in a pool.

Parameters

Parameter

Comments

client_cert

aliases: cert_file

path

The client certificate file path.

If not specified, it defaults to $HOME/.config/lxc/client.crt.

client_key

aliases: key_file

path

The client certificate key file path.

If not specified, it defaults to $HOME/.config/lxc/client.key.

name

string

Name of a specific storage volume to retrieve information about.

If not specified, information about all volumes in the pool are returned.

pool

string / required

Name of the storage pool to query for volumes.

This parameter is required.

project

string

snap_url

string

The Unix domain socket path when LXD is installed by snap package manager.

Default: "unix:/var/snap/lxd/common/lxd/unix.socket"

trust_password

string

The client trusted password.

You need to set this password on the LXD server before running this module using the following command: lxc config set core.trust_password <some random password> See https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/.

If trust_password is set, this module sends a request for authentication before sending any requests.

type

string

Filter volumes by type.

Common types include container, virtual-machine, image, and custom.

If not specified, all volume types are returned.

url

string

The Unix domain socket path or the https URL for the LXD server.

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

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

This action does not modify state.

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Get information about all volumes in the default storage pool
  community.general.lxd_storage_volume_info:
    pool: default
  register: result

- name: Get information about a specific volume
  community.general.lxd_storage_volume_info:
    pool: default
    name: my-volume
  register: result

- name: Get information about all custom volumes in a pool
  community.general.lxd_storage_volume_info:
    pool: default
    type: custom
  register: result

- name: Get volume information via HTTPS connection
  community.general.lxd_storage_volume_info:
    url: https://127.0.0.1:8443
    trust_password: mypassword
    pool: default
    name: my-volume
  register: result

- name: Get volume information for a specific project
  community.general.lxd_storage_volume_info:
    project: myproject
    pool: default
  register: result

- name: Get container volumes only
  community.general.lxd_storage_volume_info:
    pool: default
    type: container
  register: result

Return Values

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

Key

Description

logs

list / elements=dictionary

The logs of requests and responses.

Returned: when ansible-playbook is invoked with -vvvv.

Sample: [{"request": {"json": null, "method": "GET", "timeout": null, "url": "/1.0/storage-pools/default/volumes"}, "response": {"json": {"status": "Success", "type": "sync"}}, "type": "sent request"}]

storage_volumes

list / elements=dictionary

List of LXD storage volumes.

Returned: success

Sample: [{"config": {"size": "10GiB"}, "content_type": "filesystem", "description": "My custom volume", "location": "none", "name": "my-volume", "type": "custom", "used_by": []}]

config

dictionary

Configuration of the storage volume.

Returned: success

content_type

string

Content type of the volume (filesystem or block).

Returned: success

description

string

Description of the storage volume.

Returned: success

location

string

Cluster member location for the volume.

Returned: success

name

string

The name of the storage volume.

Returned: success

type

string

The type of the storage volume.

Returned: success

used_by

list / elements=string

List of resources using this storage volume.

Returned: success

Authors

  • Sean McAvoy (@smcavoy)