2 - name: create disks for vm
3 with_dict: "{{ hostvars[hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[hostname].install_cooked.disks.scsi | default({})) }}"
5 vg: "{{ item.value.vg }}"
6 lv: "{{ item.value.lv }}"
7 size: "{{ item.value.size }}"
9 - name: check if vm already exists
11 name: "{{ hostname }}"
16 - name: destroy exisiting vm
18 name: "{{ hostname }}"
21 - name: wait for vm to be destroyed
23 name: "{{ hostname }}"
24 states: shutdown,crashed
27 - name: undefining exisiting vm
29 name: "{{ hostname }}"
32 when: hostname in vmhost_info
35 - name: create a temporary workdir
42 ssh_keys: "{{ hostvars[hostname].ssh_keys }}"
43 install_interface: enp1s1
44 preseed_tmpdir: "{{ tmpdir.stdout }}"
46 - name: Make preseed workdir readable by qemu
48 path: "{{ tmpdir.stdout }}"
54 - name: define new installer vm
56 name: "{{ hostname }}"
58 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
61 preseed_tmpdir: "{{ tmpdir.stdout }}"
65 name: "{{ hostname }}"
68 - name: wait for installer to start
70 name: "{{ hostname }}"
75 msg: "you can check on the status of the installer running this command 'virsh console {{ hostname }}' on host {{ inventory_hostname }}."
77 - name: wait for installer to finish or crash
79 name: "{{ hostname }}"
80 states: shutdown,crashed
82 register: installer_result
83 failed_when: installer_result.failed or installer_result.state == "crashed"
85 - name: undefining installer vm
87 name: "{{ hostname }}"
91 - name: cleanup temporary workdir
93 path: "{{ tmpdir.stdout }}"
96 - name: define new production vm
98 name: "{{ hostname }}"
100 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
106 name: "{{ hostname }}"
109 - name: mark vm as autostarted
111 name: "{{ hostname }}"
112 autostart: "{{ hostvars[hostname].install_cooked.autostart }}"
113 command: info ## virt module needs either command or state
114 when: hostvars[hostname].install_cooked.autostart is defined