# setup a virt instance using a dizzying array of variables :) # FIXME # do an action here that aborts if a bunch of vars are not set - name: get vm list on "{{ vmhost }}" delegate_to: "{{ vmhost }}" virt: command=list_vms register: result always_run: yes - name: ensure the lv for the guest is made on {{ vmhost }} lvol: lv={{ inventory_hostname }} vg={{ volgroup }} size={{ lvm_size }} state=present delegate_to: "{{ vmhost }}" when: inventory_hostname not in result.list_vms - name: run the virt-install on "{{ vmhost }}" shell: "{{ virt_install_command }}" delegate_to: "{{ vmhost }}" when: inventory_hostname not in result.list_vms - name: wait for the install to finish on "{{ vmhost }}" virt: command=status name={{ inventory_hostname }} register: vmstatus until: vmstatus.status == 'shutdown' delegate_to: "{{ vmhost }}" retries: 150 delay: 10 when: inventory_hostname not in result.list_vms - name: start the vm up on "{{ vmhost }}" action: virt state=running name={{ inventory_hostname }} delegate_to: "{{ vmhost }}" when: inventory_hostname not in result.list_vms - name: set it to autostart on "{{ vmhost }}" action: virt command=autostart name={{ inventory_hostname }} delegate_to: "{{ vmhost }}" when: inventory_hostname not in result.list_vms - name: wait for ssh on the vm to start back local_action: wait_for delay=10 host={{ inventory_hostname }} port=22 state=started timeout=1200 when: inventory_hostname not in result.list_vms