2 - name: generate preseed file
4 src: "preseed_{{ vmdistro }}-{{ vmdistcodename }}.cfg.j2"
5 dest: "{{ vm_host.installer.preseed_path }}/vm-{{ vmname }}-{{ vmdistro }}-{{ vmdistcodename }}.cfg"
7 - name: create disks for vm
8 with_dict: "{{ hostvars[vmname].vm_install_cooked.disks.virtio | default({}) | combine(hostvars[vmname].vm_install_cooked.disks.scsi | default({})) }}"
10 vg: "{{ item.value.vg }}"
11 lv: "{{ item.value.lv }}"
12 size: "{{ item.value.size }}"
14 - name: check if vm already exists
20 - name: destroy exisiting vm
24 when: vmname in vmhost_info
26 - name: wait for vm to be destroyed
29 states: shutdown,crashed
31 when: vmname in vmhost_info
33 - name: undefining exisiting vm
37 when: vmname in vmhost_info
39 - name: enable installer in VM config
43 - name: define new installer vm
47 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
54 - name: wait for installer to start
61 msg: "you can check on the status of the installer running this command 'virsh console {{ vmname }}' on host {{ inventory_hostname }}."
63 - name: wait for installer to finish or crash
66 states: shutdown,crashed
68 register: installer_result
69 failed_when: installer_result.failed or installer_result.state == "crashed"
71 - name: undefining installer vm
76 - name: disable installer in VM config
80 - name: define new production vm
84 xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
91 - name: mark vm as autostarted
94 autostart: "{{ hostvars[vmname].vm_install_cooked.autostart }}"
95 command: info ## virt module needs either command or state
96 when: hostvars[vmname].vm_install_cooked.autostart is defined