vm-setup/roles/setup-libvirt/tasks/main.yml
2022-06-16 20:43:06 +02:00

63 lines
1.4 KiB
YAML

---
- name: install libvirt and tools
package:
name:
- libvirt-daemon-system
- qemu-system
state: latest
- name: Make sure config directory exists
file:
path: /etc/systemd/network
state: directory
- name: copy network config
template:
src: "{{ item }}"
dest: "/etc/systemd/network/"
with_items:
- "br0.netdev"
- "br0.network"
- "ethernet.network"
- name: check if /etc/network/interfaces exists
stat: path="/etc/network/interfaces"
register: interfaces
- name: disable /etc/network/interfaces
command: mv /etc/network/interfaces /etc/network/interfaces.disabled
when: interfaces.stat.exists
- name: start and enable systemd-networkd
service: name=systemd-networkd state=restarted enabled=yes
- name: start and enable systemd-resolved
service: name=systemd-resolved state=restarted enabled=yes
- name: Disable old network scripts and NetworkManager
service:
name: "{{ item }}"
enabled: no
state: stopped
with_items:
- networking
- network-manager
- NetworkManager
ignore_errors: true
- name: Make a symlink for resolv.conf to use systemd-resolved
file:
dest: /etc/resolv.conf
src: /run/systemd/resolve/stub-resolv.conf
- name: Create libvirt bridge config
copy:
dest: /etc/qemu/bridge.conf
content: "allow br0"
- name: setuid for qemu-bridge-helper
file:
path: /usr/lib/qemu/qemu-bridge-helper
mode: 04755