-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirt-manager.yml
30 lines (24 loc) · 971 Bytes
/
virt-manager.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Expiremental Virt manager script
---
- name: Setup virt-manager prerequisites
hosts: localhost
become: true
tasks:
- name: Check if libvirt is included in firewall zones
command: firewall-cmd --get-zones
register: firewall_zones
- name: Restart firewall service if libvirt and libvirt-routed are in zones
systemd:
name: firewalld
state: restarted
when: "'libvirt' in firewall_zones.stdout and 'libvirt-routed' in firewall_zones.stdout"
- name: Check for an active default network in virsh
command: virsh net-list --all
register: virsh_networks
- name: Start the default network in virsh if not active
command: virsh net-start default
when: "'default' not in virsh_networks.stdout"
- name: Add user to libvirt-sock group
command: chown {{ ansible_user_id }}:{{ ansible_user_id }} /var/run/libvirt/libvirt-sock
args:
creates: /var/run/libvirt/libvirt-sock