blob: 89378244befb405e99edfdc60e21e987c4f72e75 [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 Williams35624562016-08-28 17:12:26 -07004- name: Check to see if we already have a uvtool image
5 find:
6 path: "/var/lib/uvtool/libvirt/images"
7 patterns: "x-uvt-b64-*"
8 register: uvtool_image
9
Zack Williamsd31bbc92016-05-20 11:43:18 -070010- name: Get ubuntu image for uvtool
Zack Williams35624562016-08-28 17:12:26 -070011 when: "{{ uvtool_image.matched < 1 }}"
Zack Williamsd31bbc92016-05-20 11:43:18 -070012 command: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily \
13 release={{ ansible_distribution_release }} arch=amd64
Zack Williams35624562016-08-28 17:12:26 -070014 args:
15 creates: "/var/lib/uvtool/libvirt/images/x-uvt-b64-*"
Zack Williamsd31bbc92016-05-20 11:43:18 -070016 async: 1200
17 poll: 0
18 register: uvt_sync
19
Zack Williams81470de2016-04-11 12:44:38 -070020- name: collect libvirt network facts
21 virt_net:
22 command=facts
23
24- name: Tear down libvirt's default network
Andy Bavier0481a8a2016-07-14 13:01:45 +020025 when: not on_maas and ansible_libvirt_networks["default"] is defined
Zack Williams81470de2016-04-11 12:44:38 -070026 virt_net:
27 command={{ item }}
28 name=default
29 with_items:
30 - destroy
31 - undefine
32
33# note, this isn't idempotent, so may need manual fixing if it changes
34- name: define libvirt networks IP/DHCP/DNS settings
Zack Williams6f5a6e72016-08-10 17:45:27 -070035 when: not on_maas
Zack Williams81470de2016-04-11 12:44:38 -070036 virt_net:
37 name=xos-{{ item.name }}
38 command=define
39 xml='{{ lookup("template", "virt_net.xml.j2") }}'
40 with_items: '{{ virt_nets }}'
41
Zack Williams351c6682016-04-12 10:32:38 -070042- name: collect libvirt network facts after defining new network
Zack Williams6f5a6e72016-08-10 17:45:27 -070043 when: not on_maas
Zack Williams351c6682016-04-12 10:32:38 -070044 virt_net:
45 command=facts
46
Zack Williams81470de2016-04-11 12:44:38 -070047- name: start libvirt networks
Andy Bavier0481a8a2016-07-14 13:01:45 +020048 when: not on_maas and ansible_libvirt_networks["xos-{{ item.name }}"].state != "active"
Zack Williams81470de2016-04-11 12:44:38 -070049 virt_net:
50 name=xos-{{ item.name }}
51 command=create
52 with_items: '{{ virt_nets }}'
53
54- name: have libvirt networks autostart
Andy Bavier0481a8a2016-07-14 13:01:45 +020055 when: not on_maas and ansible_libvirt_networks["xos-{{ item.name }}"].autostart != "yes"
Zack Williams81470de2016-04-11 12:44:38 -070056 virt_net:
57 name=xos-{{ item.name }}
58 autostart=yes
59 with_items: '{{ virt_nets }}'
Zack Williams709f11b2016-03-17 14:29:51 -070060
Zack Williamsc3cde842016-05-20 12:02:33 -070061- name: Wait for uvt-kvm image to be available
Zack Williams35624562016-08-28 17:12:26 -070062 when: "{{ uvtool_image.matched < 1 }}"
Zack Williamsc3cde842016-05-20 12:02:33 -070063 async_status: jid={{ uvt_sync.ansible_job_id }}
64 register: uvt_sync_result
65 until: uvt_sync_result.finished
66 delay: 10
67 retries: 120