blob: da7b2394485d30d04a3841a9d884fe2d433c70a2 [file] [log] [blame]
Zack Williams709f11b2016-03-17 14:29:51 -07001---
Zack Williamsc3cde842016-05-20 12:02:33 -07002# roles/config-virt/tasks/main.yml
Zack Williams709f11b2016-03-17 14:29:51 -07003
Zack Williamsd31bbc92016-05-20 11:43:18 -07004- name: Get ubuntu image for uvtool
5 command: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily \
6 release={{ ansible_distribution_release }} arch=amd64
7 async: 1200
8 poll: 0
9 register: uvt_sync
10
Zack Williams81470de2016-04-11 12:44:38 -070011- name: collect libvirt network facts
12 virt_net:
13 command=facts
14
15- name: Tear down libvirt's default network
16 when: ansible_libvirt_networks["default"] is defined
17 virt_net:
18 command={{ item }}
19 name=default
20 with_items:
21 - destroy
22 - undefine
23
24# note, this isn't idempotent, so may need manual fixing if it changes
25- name: define libvirt networks IP/DHCP/DNS settings
26 virt_net:
27 name=xos-{{ item.name }}
28 command=define
29 xml='{{ lookup("template", "virt_net.xml.j2") }}'
30 with_items: '{{ virt_nets }}'
31
Zack Williams351c6682016-04-12 10:32:38 -070032- name: collect libvirt network facts after defining new network
33 virt_net:
34 command=facts
35
Zack Williams81470de2016-04-11 12:44:38 -070036- name: start libvirt networks
37 when: ansible_libvirt_networks["xos-{{ item.name }}"].state != "active"
38 virt_net:
39 name=xos-{{ item.name }}
40 command=create
41 with_items: '{{ virt_nets }}'
42
43- name: have libvirt networks autostart
44 when: ansible_libvirt_networks["xos-{{ item.name }}"].autostart != "yes"
45 virt_net:
46 name=xos-{{ item.name }}
47 autostart=yes
48 with_items: '{{ virt_nets }}'
Zack Williams709f11b2016-03-17 14:29:51 -070049
50- name: Have libvirt enable port forwarding to VM's
51 become: yes
52 template:
53 src={{ item }}.j2
54 dest=/etc/libvirt/hooks/{{ item }}
55 mode=0755 owner=root
56 with_items:
57 - daemon
58 - qemu
59 notify:
60 - reload libvirt-bin
61 - run qemu hook
62
Zack Williamsc3cde842016-05-20 12:02:33 -070063- name: Wait for uvt-kvm image to be available
64 async_status: jid={{ uvt_sync.ansible_job_id }}
65 register: uvt_sync_result
66 until: uvt_sync_result.finished
67 delay: 10
68 retries: 120