ansible-roles/system/extra/libvirt/tasks/main.yml

46 lines
1.1 KiB
YAML

---
- name: "install libvirt"
ansible.builtin.apt:
name:
- "dnsmasq"
- "libvirt-daemon-system"
- "netcat"
- "qemu-system"
install_recommends: false
register: system_extra_libvirt_install
- name: "install zfs storage driver for libvirt"
ansible.builtin.apt:
name:
- "libvirt-daemon-driver-storage-zfs"
when:
system_extra_libvirt_install_zfs_driver
register: system_extra_libvirt_zfs_driver
- name: "enable libvirtd"
ansible.builtin.systemd:
name: "libvirtd"
enabled: true
- name: "start libvirtd"
ansible.builtin.systemd:
name: "libvirtd"
state: "started"
register: system_extra_libvirt_start
- name: "restart libvirtd"
ansible.builtin.systemd:
name: "libvirtd"
state: "restarted"
when:
(system_extra_libvirt_install.changed or
(system_extra_libvirt_zfs_driver is defined and
system_extra_libvirt_zfs_driver.changed)) and
not system_extra_libvirt_start.changed
- name: "add {{ system_extra_libvirt_user_name }} to group \"libvirt\""
ansible.builtin.user:
name: "{{ system_extra_libvirt_user_name }}"
groups: "libvirt"
append: true