Getting started

The management of the libvirt daemon is split into a few Ansible roles to allow easier control over a lot of configuration options. The roles are meant to be used together, with only the main role taking care of the environment itself. See the example playbook provided with the main role to see how they are used together.

The debops.libvirtd role will install libvirtd along with virtualization components required on the server. It manages the configuration of the main libvirtd daemon process. The role detects if the OpenNebula environment is enabled using the specific Ansible inventory groups and enables support for OpenNebula in libvirt.

The debops.libvirtd_qemu role manages the configuration of the QEMU/KVM virtualization environment. The role supports custom configuration required by OpenNebula nodes, which is enabled automatically when OpenNebula environment is detected by the main role.

Example inventory

This role should be enabled on virtualization hosts, you can do this by adding a host to the [debops_service_libvirtd] group:


Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.libvirtd role:


- name: Install and manage libvirtd
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_libvirtd' ]
  become: True

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'


    - role: apt_preferences
      tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
        - '{{ libvirtd__apt_preferences__dependent_list }}'

    - role: nsswitch
      tags: [ 'role::nsswitch', 'skip::nsswitch' ]
        - '{{ libvirtd__nsswitch__dependent_services }}'

    - role: ferm
      tags: [ 'role::ferm', 'skip::ferm' ]
        - '{{ libvirtd__ferm__dependent_rules }}'
        - '{{ libvirtd_qemu__ferm__dependent_rules }}'

    - role: python
      tags: [ 'role::python', 'skip::python' ]
        - '{{ libvirtd__python__dependent_packages3 }}'
        - '{{ libvirtd__python__dependent_packages2 }}'

    - role: libvirtd
      tags: [ 'role::libvirtd', 'skip::libvirtd' ]

    - role: libvirtd_qemu
      tags: [ 'role::libvirtd_qemu', 'skip::libvirtd_qemu', 'role::libvirtd', 'skip::libvirtd' ]

Ansible tags

You can use Ansible --tags or --skip-tags parameters to limit what tasks are performed during Ansible run. This can be used after a host was first configured to speed up playbook execution, when you are sure that most of the configuration is already in the desired state.

Available role tags:

Main role tag, should be used in the playbook to execute all of the role tasks as well as role dependencies.