--- - 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 # TODO: this keeps adding the line over and over again lineinfile: path: /etc/nsswitch.conf regexp: '^hosts: (.+)' line: 'hosts: libvirt libvirt_guest \1' state: present backrefs: true backup: true