50 lines
1.1 KiB
YAML
50 lines
1.1 KiB
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: Put 'libvirt libvirt_guest' in /etc/nsswitch.conf
|
|
become: true
|
|
vars:
|
|
nsswitch_content: "{{ lookup('file', '/etc/nsswitch.conf') }}"
|
|
lineinfile:
|
|
path: /etc/nsswitch.conf
|
|
regexp: '^hosts: (.+)'
|
|
line: 'hosts: libvirt libvirt_guest \1'
|
|
state: present
|
|
backrefs: true
|
|
backup: true
|
|
when: "'libvirt libvirt_guest' not in nsswitch_content"
|
|
notify: Enable libvirtd service
|
|
|
|
- name: Define session pool
|
|
virt_pool:
|
|
command: define
|
|
name: "{{ pool_name }}"
|
|
uri: "qemu:///session"
|
|
xml: "{{ lookup('template', 'libvirt-pool.xml.j2') }}"
|
|
|
|
- name: Start session pool
|
|
virt_pool:
|
|
state: active
|
|
autostart: true
|
|
name: "{{ pool_name }}"
|
|
uri: "qemu:///session"
|