blob: 659a521a5e402e45a02a98d29f0467228aadea01 [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
Zack Williams351c6682016-04-12 10:32:38 -070025- name: collect libvirt network facts after defining new network
26 virt_net:
27 command=facts
28
Zack Williams81470de2016-04-11 12:44:38 -070029- name: start libvirt networks
30 when: ansible_libvirt_networks["xos-{{ item.name }}"].state != "active"
31 virt_net:
32 name=xos-{{ item.name }}
33 command=create
34 with_items: '{{ virt_nets }}'
35
36- name: have libvirt networks autostart
37 when: ansible_libvirt_networks["xos-{{ item.name }}"].autostart != "yes"
38 virt_net:
39 name=xos-{{ item.name }}
40 autostart=yes
41 with_items: '{{ virt_nets }}'
Zack Williams709f11b2016-03-17 14:29:51 -070042
43- name: Have libvirt enable port forwarding to VM's
44 become: yes
45 template:
46 src={{ item }}.j2
47 dest=/etc/libvirt/hooks/{{ item }}
48 mode=0755 owner=root
49 with_items:
50 - daemon
51 - qemu
52 notify:
53 - reload libvirt-bin
54 - run qemu hook
55
Zack Williams709f11b2016-03-17 14:29:51 -070056