community.libvirt.virt_pool (1.3.0) — module

Manage libvirt storage pools

Authors: Maciej Delmanowski (@drybjed)

Install collection

Install with ansible-galaxy collection install community.libvirt:==1.3.0


Add to requirements.yml

  collections:
    - name: community.libvirt
      version: 1.3.0

Description

Manage I(libvirt) storage pools.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Define a new storage pool
  community.libvirt.virt_pool:
    command: define
    name: vms
    xml: '{{ lookup("template", "pool/dir.xml.j2") }}'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Build a storage pool if it does not exist
  community.libvirt.virt_pool:
    command: build
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Start a storage pool
  community.libvirt.virt_pool:
    command: create
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: List available pools
  community.libvirt.virt_pool:
    command: list_pools
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get XML data of a specified pool
  community.libvirt.virt_pool:
    command: get_xml
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Stop a storage pool
  community.libvirt.virt_pool:
    command: destroy
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a storage pool (destroys contents)
  community.libvirt.virt_pool:
    command: delete
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Undefine a storage pool
  community.libvirt.virt_pool:
    command: undefine
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Gather facts about storage pools
# Facts will be available as 'ansible_libvirt_pools'
- name: Gather facts about storage pools
  community.libvirt.virt_pool:
    command: facts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure that a pool is active (needs to be defined and built first)
  community.libvirt.virt_pool:
    state: active
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure that a pool is inactive
  community.libvirt.virt_pool:
    state: inactive
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure that a given pool will be started at boot
  community.libvirt.virt_pool:
    autostart: true
    name: vms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disable autostart for a given pool
  community.libvirt.virt_pool:
    autostart: false
    name: vms

Inputs

    
uri:
    default: qemu:///system
    description:
    - Libvirt connection uri.
    type: str

xml:
    description:
    - XML document used with the define command.
    - Must be raw XML content using C(lookup). XML cannot be reference to a file.
    type: str

mode:
    choices:
    - new
    - repair
    - resize
    - no_overwrite
    - overwrite
    - normal
    - zeroed
    description:
    - Pass additional parameters to 'build' or 'delete' commands.
    type: str

name:
    aliases:
    - pool
    description:
    - Name of the storage pool being managed. Note that pool must be previously defined
      with xml.
    type: str

state:
    choices:
    - active
    - inactive
    - present
    - absent
    - undefined
    - deleted
    description:
    - 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 is missing, you need to specify xml argument. If 'inactive', pool will be
      stopped. If 'undefined' or 'absent', pool will be removed from I(libvirt) configuration.
      If 'deleted', pool contents will be deleted and then pool undefined.
    type: str

command:
    choices:
    - define
    - build
    - create
    - start
    - stop
    - destroy
    - delete
    - undefine
    - get_xml
    - list_pools
    - facts
    - info
    - status
    - refresh
    description:
    - In addition to state management, various non-idempotent commands are available.
      See examples.
    type: str

autostart:
    description:
    - Specify if a given storage pool should be started automatically on system boot.
    type: bool