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
|
2022-05-11 17:20:57 -05:00
|
|
|
- qemu-base
|
|
|
|
- qemu-emulators-full
|
2022-01-25 23:54:43 -06:00
|
|
|
- ddrescue
|
|
|
|
state: present
|
2022-11-20 20:03:01 -06:00
|
|
|
|
2022-01-25 23:54:43 -06:00
|
|
|
- name: Copy VM definitions
|
|
|
|
become: yes
|
|
|
|
register: vmdefs
|
2022-11-20 20:03:01 -06:00
|
|
|
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
|
2022-11-20 20:03:01 -06:00
|
|
|
systemd:
|
2022-01-25 23:54:43 -06:00
|
|
|
daemon_reload: yes
|
|
|
|
|
|
|
|
- name: QEMU Bridge Config
|
|
|
|
become: yes
|
2022-05-11 17:20:57 -05:00
|
|
|
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
|
2022-05-11 17:20:57 -05:00
|
|
|
when: qemubr.changed
|
2022-01-25 23:54:43 -06:00
|
|
|
register: br0
|
2022-05-11 17:20:57 -05:00
|
|
|
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
|
2022-05-11 17:20:57 -05:00
|
|
|
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'"
|
2022-05-11 17:20:57 -05:00
|
|
|
|
|
|
|
- name: Remind about restarting VMs
|
|
|
|
when: qemubr.changed or br0.changed
|
|
|
|
debug:
|
|
|
|
msg: You may need to restart VMs on the Node.
|
2024-04-01 00:53:08 -05:00
|
|
|
|
|
|
|
- name: Enable VMs
|
|
|
|
become: yes
|
|
|
|
with_items: "{{ active_vms }}"
|
|
|
|
service:
|
|
|
|
name: "{{ item }}-vm.service"
|
|
|
|
state: started
|
|
|
|
enabled: yes
|