1
0
IaC/ansible/roles/hypervisor_qcow/tasks/main.yaml

51 lines
1.2 KiB
YAML
Raw Normal View History

2023-08-09 04:38:34 -04:00
---
- name: Install libvirt packages (Arch)
when: ansible_os_distribution == 'Archlinux'
community.general.pacman:
name: "{{ libvirt_packages['Arch'] }}"
state: present
update_cache: true
- name: Add user to libvirt group
ansible.builtin.user:
name: "{{ ansible_user }}"
groups: libvirt
append: true
- name: Add bridge(s) to qemu_bridge_helper
when: qemu_bridges is defined
ansible.builtin.lineinfile:
path: /etc/qemu/bridge.conf
line: "{{ item }}"
state: present
backup: false
insertafter: EOF
loop: "{{ qemu_bridges | default(['virbr0']) }}"
- name: Start and enable libvirt service
ansible.builtin.service:
name: libvirtd.service
state: started
enabled: true
- name: Stop the default libvirt network
community.libvirt.virt_net:
name: default
state: inactive
- name: Remove default libvirt network
community.libvirt.virt_net:
name: default
state: absent
2023-08-10 09:32:17 -04:00
- name: Setup libvirt storage (qcow)
when: hypervisor.storage == 'dir'
ansible.builtin.include_tasks:
file: libvirt_dir.yaml
- name: Setup libvirt storage (zfs)
when: hypervisor.storage == 'zfs'
ansible.builtin.include_tasks:
file: libvirt_zfs.yaml