blob: fb748fa24328ac92653a101046d969f05f2284eb [file] [log] [blame]
Zack Williams709f11b2016-03-17 14:29:51 -07001---
Zack Williamsef434f82016-04-07 17:15:39 -07002# roles/config-virt/tasks/main.yml
Zack Williams709f11b2016-03-17 14:29:51 -07003
Zack Williams81470de2016-04-11 12:44:38 -07004- name: collect libvirt network facts
5 virt_net:
6 command=facts
7
8- name: Tear down libvirt's default network
9 when: ansible_libvirt_networks["default"] is defined
10 virt_net:
11 command={{ item }}
12 name=default
13 with_items:
14 - destroy
15 - undefine
16
17# note, this isn't idempotent, so may need manual fixing if it changes
18- name: define libvirt networks IP/DHCP/DNS settings
19 virt_net:
20 name=xos-{{ item.name }}
21 command=define
22 xml='{{ lookup("template", "virt_net.xml.j2") }}'
23 with_items: '{{ virt_nets }}'
24
25- name: start libvirt networks
26 when: ansible_libvirt_networks["xos-{{ item.name }}"].state != "active"
27 virt_net:
28 name=xos-{{ item.name }}
29 command=create
30 with_items: '{{ virt_nets }}'
31
32- name: have libvirt networks autostart
33 when: ansible_libvirt_networks["xos-{{ item.name }}"].autostart != "yes"
34 virt_net:
35 name=xos-{{ item.name }}
36 autostart=yes
37 with_items: '{{ virt_nets }}'
Zack Williams709f11b2016-03-17 14:29:51 -070038
39- name: Have libvirt enable port forwarding to VM's
40 become: yes
41 template:
42 src={{ item }}.j2
43 dest=/etc/libvirt/hooks/{{ item }}
44 mode=0755 owner=root
45 with_items:
46 - daemon
47 - qemu
48 notify:
49 - reload libvirt-bin
50 - run qemu hook
51
Zack Williams709f11b2016-03-17 14:29:51 -070052