blob: 89c0c7db85b81a706e1adfed239a0c9c4e4f8737 [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
Andy Bavier0481a8a2016-07-14 13:01:45 +020016 when: not on_maas and ansible_libvirt_networks["default"] is defined
Zack Williams81470de2016-04-11 12:44:38 -070017 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
Zack Williams6f5a6e72016-08-10 17:45:27 -070026 when: not on_maas
Zack Williams81470de2016-04-11 12:44:38 -070027 virt_net:
28 name=xos-{{ item.name }}
29 command=define
30 xml='{{ lookup("template", "virt_net.xml.j2") }}'
31 with_items: '{{ virt_nets }}'
32
Zack Williams351c6682016-04-12 10:32:38 -070033- name: collect libvirt network facts after defining new network
Zack Williams6f5a6e72016-08-10 17:45:27 -070034 when: not on_maas
Zack Williams351c6682016-04-12 10:32:38 -070035 virt_net:
36 command=facts
37
Zack Williams81470de2016-04-11 12:44:38 -070038- name: start libvirt networks
Andy Bavier0481a8a2016-07-14 13:01:45 +020039 when: not on_maas and ansible_libvirt_networks["xos-{{ item.name }}"].state != "active"
Zack Williams81470de2016-04-11 12:44:38 -070040 virt_net:
41 name=xos-{{ item.name }}
42 command=create
43 with_items: '{{ virt_nets }}'
44
45- name: have libvirt networks autostart
Andy Bavier0481a8a2016-07-14 13:01:45 +020046 when: not on_maas and ansible_libvirt_networks["xos-{{ item.name }}"].autostart != "yes"
Zack Williams81470de2016-04-11 12:44:38 -070047 virt_net:
48 name=xos-{{ item.name }}
49 autostart=yes
50 with_items: '{{ virt_nets }}'
Zack Williams709f11b2016-03-17 14:29:51 -070051
Zack Williamsc3cde842016-05-20 12:02:33 -070052- name: Wait for uvt-kvm image to be available
53 async_status: jid={{ uvt_sync.ansible_job_id }}
54 register: uvt_sync_result
55 until: uvt_sync_result.finished
56 delay: 10
57 retries: 120