diff --git a/system/extra/libvirt/meta/argument_specs.yml b/system/extra/libvirt/meta/argument_specs.yml new file mode 100644 index 0000000..4d8b67c --- /dev/null +++ b/system/extra/libvirt/meta/argument_specs.yml @@ -0,0 +1,10 @@ +--- +argument_specs: + main: + options: + system_extra_libvirt_user_name: + type: "str" + required: true + system_extra_libvirt_install_zfs_driver: + type: "bool" + required: true diff --git a/system/extra/libvirt/tasks/main.yml b/system/extra/libvirt/tasks/main.yml new file mode 100644 index 0000000..45c410c --- /dev/null +++ b/system/extra/libvirt/tasks/main.yml @@ -0,0 +1,45 @@ +--- +- 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