2013-05-03 16:56:38 +00:00
|
|
|
# setup a virt instance using a dizzying array of variables :)
|
2013-05-03 16:58:47 +00:00
|
|
|
# FIXME
|
|
|
|
# do an action here that aborts if a bunch of vars are not set
|
|
|
|
|
2013-05-03 16:56:38 +00:00
|
|
|
- name: get vm list on the vmhost
|
2013-11-25 18:36:54 +00:00
|
|
|
delegate_to: {{ vmhost }}
|
2013-05-03 16:56:38 +00:00
|
|
|
virt: command=list_vms
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: ensure the lv for the host is made
|
2013-11-25 18:33:35 +00:00
|
|
|
lvol: lv={{ inventory_hostname }} vg={{ volgroup }} size={{ lvm_size }} state=present
|
2013-11-25 18:36:54 +00:00
|
|
|
delegate_to: {{ vmhost }}
|
2013-06-11 16:29:13 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
|
|
|
- name: run the virt-install
|
2013-11-25 18:33:35 +00:00
|
|
|
shell: "{{ virt_install_command }}"
|
2013-11-25 18:36:54 +00:00
|
|
|
delegate_to: {{ vmhost }}
|
2013-06-11 16:29:13 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
|
|
|
- name: wait for the install to finish - by watching the domstate
|
|
|
|
# this just keeps checking the domstate until it stops running
|
2013-11-25 18:36:54 +00:00
|
|
|
shell: while `/usr/bin/virsh domstate {{ inventory_hostname }} | grep -q running` ; do sleep 10; done
|
|
|
|
delegate_to: {{ vmhost }}
|
2013-05-03 16:56:38 +00:00
|
|
|
async: 1200
|
|
|
|
poll: 10
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
|
|
|
- name: start the vm up
|
2013-11-25 18:33:35 +00:00
|
|
|
action: virt state=running name={{ inventory_hostname }}
|
2013-11-25 18:36:54 +00:00
|
|
|
delegate_to: {{ vmhost }}
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
|
|
|
- name: wait for ssh on the vm to start back
|
2013-11-25 18:33:35 +00:00
|
|
|
local_action: wait_for delay=10 host={{ inventory_hostname }} port=22 state=started timeout=1200
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-06-11 16:29:13 +00:00
|
|
|
|
2013-05-03 16:56:38 +00:00
|
|
|
|
|
|
|
|