From f632ec4b69f9b73fd607b0bd6793b437e7aa9ffc Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Thu, 23 Feb 2023 22:43:37 +0100 Subject: [PATCH] Add libvirt installation and setup to music/rip --- inventory/host_vars/yggdrasil/vars.yml | 2 + .../roles/music/rip/tasks/include/libvirt.yml | 46 +++++++++++++++++++ .../roles/music/rip/tasks/include/user.yml | 2 +- playbooks/roles/music/rip/tasks/main.yml | 5 ++ roles | 2 +- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 playbooks/roles/music/rip/tasks/include/libvirt.yml diff --git a/inventory/host_vars/yggdrasil/vars.yml b/inventory/host_vars/yggdrasil/vars.yml index 59bd4e3..412bc77 100644 --- a/inventory/host_vars/yggdrasil/vars.yml +++ b/inventory/host_vars/yggdrasil/vars.yml @@ -23,6 +23,8 @@ system_mail_smtp_pass: "{{ vault_system_mail_smtp_pass }}" system_base_additional_ssh_users: - "music" system_base_udp_ports: + - 67 # dhcp (libvirt) + - 68 # dhcp (libvirt) - 137 # samba - 138 # samba system_base_tcp_ports: diff --git a/playbooks/roles/music/rip/tasks/include/libvirt.yml b/playbooks/roles/music/rip/tasks/include/libvirt.yml new file mode 100644 index 0000000..09f3f6c --- /dev/null +++ b/playbooks/roles/music/rip/tasks/include/libvirt.yml @@ -0,0 +1,46 @@ +--- +- name: "libvirt : install libvirt" + ansible.builtin.apt: + name: + - "dnsmasq" + - "libvirt-daemon-system" + - "netcat" + - "qemu-system" + install_recommends: false + register: music_rip_libvirt_install + +- name: "libvirt : install zfs storage driver for libvirt" + ansible.builtin.apt: + name: + - "libvirt-daemon-driver-storage-zfs" + when: + "'zfs' in group_names" + register: music_rip_libvirt_zfs_install + +- name: "libvirt : enable libvirtd" + ansible.builtin.systemd: + name: "libvirtd" + enabled: true + +- name: "libvirt : start libvirtd" + ansible.builtin.systemd: + name: "libvirtd" + state: "started" + register: music_rip_libvirt_start + +- name: "libvirt : restart libvirtd" + ansible.builtin.systemd: + name: "libvirtd" + state: "restarted" + when: + (music_rip_libvirt_install.changed or + (music_rip_libvirt_zfs_install is defined and + music_rip_libvirt_zfs_install.changed)) and + not music_rip_libvirt_start.changed + + +- name: "libvirt : add {{ music_user_name }} to group \"libvirt\"" + ansible.builtin.user: + name: "{{ music_user_name }}" + groups: "libvirt" + append: true diff --git a/playbooks/roles/music/rip/tasks/include/user.yml b/playbooks/roles/music/rip/tasks/include/user.yml index a922c2b..3e57a11 100644 --- a/playbooks/roles/music/rip/tasks/include/user.yml +++ b/playbooks/roles/music/rip/tasks/include/user.yml @@ -10,7 +10,7 @@ - name: "rip : set default shell" ansible.builtin.user: name: "{{ music_user_name }}" - shell: "/usr/bin/rbash" + shell: "/usr/bin/bash" - block: diff --git a/playbooks/roles/music/rip/tasks/main.yml b/playbooks/roles/music/rip/tasks/main.yml index 76b509a..79e4351 100644 --- a/playbooks/roles/music/rip/tasks/main.yml +++ b/playbooks/roles/music/rip/tasks/main.yml @@ -13,3 +13,8 @@ ansible.builtin.import_tasks: "include/samba.yml" tags: - "music:rip:samba" + +- name: "play:music : role:rip : tasks:libvirt" + ansible.builtin.import_tasks: "include/libvirt.yml" + tags: + - "music:rip:libvirt" diff --git a/roles b/roles index 5d8a2e3..b22e1ba 160000 --- a/roles +++ b/roles @@ -1 +1 @@ -Subproject commit 5d8a2e3f43fb408f2a58efb5d56d874c7b713c19 +Subproject commit b22e1ba3d01252f487105de76a90eb6af402b809