2 - name: create disks for vm
3 with_dict: "{{ hostvars[vmname].vm_install_cooked.disks.virtio | default({}) | combine(hostvars[vmname].vm_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
16 - name: destroy exisiting vm
21 - name: wait for vm to be destroyed
24 states: shutdown,crashed
27 - name: undefining exisiting vm
32 when: vmname in vmhost_info
34 - name: enable installer in VM config
38 - name: define new installer vm
42 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
49 - name: wait for installer to start
56 msg: "you can check on the status of the installer running this command 'virsh console {{ vmname }}' on host {{ inventory_hostname }}."
58 - name: wait for installer to finish or crash
61 states: shutdown,crashed
63 register: installer_result
64 failed_when: installer_result.failed or installer_result.state == "crashed"
66 - name: undefining installer vm
71 - name: disable installer in VM config
75 - name: define new production vm
79 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
86 - name: mark vm as autostarted
89 autostart: "{{ hostvars[vmname].vm_install_cooked.autostart }}"
90 command: info ## virt module needs either command or state
91 when: hostvars[vmname].vm_install_cooked.autostart is defined