restructure virt to be more like cloud creation
remove a line from the todo
This commit is contained in:
parent
57c6d50f68
commit
1696cc678a
3 changed files with 38 additions and 37 deletions
34
tasks/virt_instance_create.yml
Normal file
34
tasks/virt_instance_create.yml
Normal file
|
@ -0,0 +1,34 @@
|
|||
# setup a virt instance using a dizzying array of variables :)
|
||||
- name: get vm list on the vmhost
|
||||
delegate_to: $vmhost
|
||||
virt: command=list_vms
|
||||
register: result
|
||||
|
||||
- name: ensure the lv for the host is made
|
||||
lvol: lv=$inventory_hostname_short vg=$volgroup size=$lvm_size state=present
|
||||
delegate_to: $vmhost
|
||||
when_string: ${inventory_hostname} not in ${result.list_vms}
|
||||
|
||||
- name: run the virt-install
|
||||
shell: ${install_command}
|
||||
delegate_to: $vmhost
|
||||
when_string: ${inventory_hostname} not in ${result.list_vms}
|
||||
|
||||
- name: wait for the install to finish - by watching the domstate
|
||||
# this just keeps checking the domstate until it stops running
|
||||
shell: while `/usr/bin/virsh domstate ${inventory_hostname} | grep -q running` ; do sleep 20; done
|
||||
delegate_to: $vmhost
|
||||
async: 1200
|
||||
poll: 10
|
||||
when_string: ${inventory_hostname} not in ${result.list_vms}
|
||||
|
||||
- name: start the vm up
|
||||
action: virt state=running name=${inventory_hostname}
|
||||
delegate_to: $vmhost
|
||||
when_string: ${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_string: ${inventory_hostname} not in ${result.list_vms}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue