blob: 70999d673492ee5ff10c77073c3412e301633b76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# 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 the vmhost
delegate_to: "{{ vmhost }}"
virt: command=list_vms
register: result
always_run: yes
- name: ensure the lv for the host is made
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
shell: "{{ virt_install_command }}"
delegate_to: "{{ vmhost }}"
when: 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 10; done
delegate_to: "{{ vmhost }}"
async: 1200
poll: 10
when: inventory_hostname not in result.list_vms
- name: start the vm up
action: virt state=running 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
|