W3cubDocs

/Ansible

community.libvirt.virt_pool – Manage libvirt storage pools

Note

This plugin is part of the community.libvirt collection (version 1.0.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 community.libvirt.

To use it in a playbook, specify: community.libvirt.virt_pool.

Synopsis

  • Manage libvirt storage pools.

Requirements

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

  • python >= 2.6
  • python-libvirt
  • python-lxml

Parameters

Parameter Choices/Defaults Comments
autostart
boolean
    Choices:
  • no
  • yes
Specify if a given storage pool should be started automatically on system boot.
command
string
    Choices:
  • define
  • build
  • create
  • start
  • stop
  • destroy
  • delete
  • undefine
  • get_xml
  • list_pools
  • facts
  • info
  • status
  • refresh
in addition to state management, various non-idempotent commands are available. See examples.
mode
string
    Choices:
  • new
  • repair
  • resize
  • no_overwrite
  • overwrite
  • normal
  • zeroed
Pass additional parameters to 'build' or 'delete' commands.
name
string
name of the storage pool being managed. Note that pool must be previously defined with xml.

aliases: pool
state
string
    Choices:
  • active
  • inactive
  • present
  • absent
  • undefined
  • deleted
specify which state you want a storage pool to be in. If 'active', pool will be started. If 'present', ensure that pool is present but do not change its state; if it's missing, you need to specify xml argument. If 'inactive', pool will be stopped. If 'undefined' or 'absent', pool will be removed from libvirt configuration. If 'deleted', pool contents will be deleted and then pool undefined.
uri
string
Default:
"qemu:///system"
libvirt connection uri.
xml
string
XML document used with the define command.

Examples

# Define a new storage pool
- community.libvirt.virt_pool:
    command: define
    name: vms
    xml: '{{ lookup("template", "pool/dir.xml.j2") }}'

# Build a storage pool if it does not exist
- community.libvirt.virt_pool:
    command: build
    name: vms

# Start a storage pool
- community.libvirt.virt_pool:
    command: create
    name: vms

# List available pools
- community.libvirt.virt_pool:
    command: list_pools

# Get XML data of a specified pool
- community.libvirt.virt_pool:
    command: get_xml
    name: vms

# Stop a storage pool
- community.libvirt.virt_pool:
    command: destroy
    name: vms

# Delete a storage pool (destroys contents)
- community.libvirt.virt_pool:
    command: delete
    name: vms

# Undefine a storage pool
- community.libvirt.virt_pool:
    command: undefine
    name: vms

# Gather facts about storage pools
# Facts will be available as 'ansible_libvirt_pools'
- community.libvirt.virt_pool:
    command: facts

# Gather information about pools managed by 'libvirt' remotely using uri
- community.libvirt.virt_pool:
    command: info
    uri: '{{ item }}'
  with_items: '{{ libvirt_uris }}'
  register: storage_pools

# Ensure that a pool is active (needs to be defined and built first)
- community.libvirt.virt_pool:
    state: active
    name: vms

# Ensure that a pool is inactive
- community.libvirt.virt_pool:
    state: inactive
    name: vms

# Ensure that a given pool will be started at boot
- community.libvirt.virt_pool:
    autostart: yes
    name: vms

# Disable autostart for a given pool
- community.libvirt.virt_pool:
    autostart: no
    name: vms

Authors

  • Maciej Delmanowski (@drybjed)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_pool_module.html