setup-cockpit/roles/libvirt/tasks/main.yml
2022-03-04 09:29:29 +01:00

42 lines
919 B
YAML

---
- fail:
when: ansible_distribution != 'Archlinux'
- name: Install packages (Archlinux)
become: true
pacman:
name:
- libvirt
- iptables-nft
- dnsmasq
- dmidecode
- virt-install
- virt-viewer
- qemu-headless
when: ansible_distribution == 'Archlinux'
- name: Add user to libvirt group
user:
name: "{{ ansible_facts['env']['USER'] }}"
append: yes
groups: libvirt
- name: Check if 'libvirt libvirt_guest' is in /etc/nsswitch.conf
become: true
lineinfile:
path: /etc/nsswitch.conf
line: libvirt libvirt_guest
state: present
check_mode: true
register: presence
- name: Put 'libvirt libvirt_guest' in /etc/nsswitch.conf
become: true
lineinfile:
path: /etc/nsswitch.conf
regexp: '^hosts: (.+)'
line: 'hosts: libvirt libvirt_guest \1'
state: present
backrefs: true
backup: true
when: presence.changed