Kapisi/roles/Node/tasks/main.yml

64 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2022-01-25 23:54:43 -06:00
---
- name: Generate VM service files from inventory
delegate_to: localhost
register: systemd_files
run_once: true
command: "python3 ../bin/generate-systemd-vms.py {{ inventory_file }}"
- name: Install virtualization packages
become: yes
package:
name:
- edk2-ovmf
- qemu-base
- qemu-emulators-full
2022-01-25 23:54:43 -06:00
- ddrescue
state: present
2022-01-25 23:54:43 -06:00
- name: Copy VM definitions
become: yes
register: vmdefs
copy:
2022-01-25 23:54:43 -06:00
src: vm-definitions/
dest: /usr/lib/systemd/system
owner: root
group: root
mode: 0644
- name: Reload systemd daemon
become: yes
when: vmdefs.changed
systemd:
2022-01-25 23:54:43 -06:00
daemon_reload: yes
- name: QEMU Bridge Config
become: yes
register: qemubr
2022-01-25 23:54:43 -06:00
copy:
src: bridge.conf
dest: /etc/qemu/bridge.conf
owner: root
group: root
mode: 0644
- name: System bridge interface
become: yes
when: qemubr.changed
2022-01-25 23:54:43 -06:00
register: br0
template:
src: netctl-bridge.j2
2022-01-25 23:54:43 -06:00
dest: /etc/netctl/br0
owner: root
group: root
mode: 0644
- name: Enable bridge
become: yes
when: qemubr.changed or br0.changed
2022-01-25 23:54:43 -06:00
command: "/bin/bash -l -c 'netctl enable br0 && netctl restart br0'"
- name: Remind about restarting VMs
when: qemubr.changed or br0.changed
debug:
msg: You may need to restart VMs on the Node.