1
0
IaC/ansible/roles/hypervisor_qcow/tasks/main.yaml
2023-08-09 18:38:34 +10:00

77 lines
1.7 KiB
YAML

---
- name: Clear systemd-networkd config directory
ansible.builtin.file:
path: "/etc/systemd/network/"
state: "{{ item }}"
owner: root
group: root
mode: '0755'
with_items:
- absent
- directory
- name: Create systemd-networkd config files
ansible.builtin.template:
src: "{{ item.src }}"
dest: /etc/systemd/network/"{{ item.name }}"
owner: root
group: root
mode: '0644'
loop: "{{ systemd_networkd_configs }}"
- name: Disable non-systemd networking services
ansible.builtin.service:
name: "{{ item }}"
state: stopped
enabled: false
loop: "{{ default_network_services[ansible_os_family] }}"
- name: Enable systemd networking
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop:
- systemd-networkd
- systemd-resolved
- 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