2012-11-21 17:56:10 +00:00
|
|
|
# pass in --limit and a vhost you wish to reboot
|
|
|
|
# talk to the vhost
|
|
|
|
# get back list of instances
|
|
|
|
# add each of their hostnames to an addhoc group
|
|
|
|
# halt each of them in a second play
|
|
|
|
# third play, reboot the vhost
|
|
|
|
# wait for vhost to come back
|
|
|
|
# wait for all of the instances to return(?)
|
|
|
|
# fail if they don't (?)
|
|
|
|
|
|
|
|
|
|
|
|
- name: find instances
|
|
|
|
hosts: $vhost
|
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: get list of guests
|
|
|
|
action: virt command=list_vms
|
|
|
|
register: vmlist
|
2012-11-21 17:59:07 +00:00
|
|
|
|
2012-11-21 17:56:10 +00:00
|
|
|
- name: add them to a bogus group
|
|
|
|
local_action: add_host hostname=$item groupname=myvms_new
|
2012-11-21 18:23:20 +00:00
|
|
|
with_items: ${vmlist.list_vms}
|
2012-11-21 17:56:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
- name: halt instances
|
|
|
|
hosts: myvms_new
|
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: echo-y
|
2012-11-21 18:22:03 +00:00
|
|
|
action: command echo "I would run halt -p"
|
2012-11-21 17:56:10 +00:00
|
|
|
|
2012-11-21 18:22:03 +00:00
|
|
|
- name: pause for 30s to let them die
|
|
|
|
local_action: pause seconds=30
|
2012-11-21 17:56:10 +00:00
|
|
|
|
2012-11-21 18:22:03 +00:00
|
|
|
- name: reboot vhost
|
|
|
|
hosts: $vhost
|
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: echo what I would do
|
|
|
|
action: command echo 'I would run halt -r"
|