# Role: libvirt

## Description

Installs and configures libvirt.

Comes with helper scripts for taking VM snapshots and adding a GPU passthrough to a VM.

https://libvirt.org/

## Usage

Using in a playbook:

```yaml
- name: Play
  hosts:
    - all
  roles:
    - samuliy.ansible.libvirt
  vars:
    ...
```

### Vars

`libvirt_memlock`:

Memlock value for VMs.

`libvirt_libvirtd_unix_sock_group`:

Value for unix_sock_group in libvirt.conf.

`libvirt_libvirtd_unix_sock_ro_perms`:

Value for unix_sock_ro_perms in libvirt.conf.

`libvirt_libvirtd_unix_sock_rw_perms`:

Value for unix_sock_rw_perms in libvirt.conf.

`libvirt_qemu_user`:

Value for user in qemu.conf.

`libvirt_qemu_group`:

Value for group in qemu.conf.

`libvirt_users`:

List of users to add to libvirt and kvm groups.

`libvirt_qemu_hooks`:

List of hooks to install for QEMU guests.

The list contains items with fields:

- 'name' - hook script name

- 'domains' - list of domains to install the hook for, or the string 'all'

- 'hook' - hook name

- 'stage' - hook stage

- 'script' - script to execute
