2013-08-12 15:47:12 +00:00
|
|
|
# requires --extra-vars="vhost=somevhost fqdn"
|
|
|
|
|
2024-11-25 18:24:56 +10:00
|
|
|
# General overview:
|
2013-08-12 15:47:12 +00:00
|
|
|
# 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
|
|
|
|
# wait for them to die
|
|
|
|
# third play, reboot the vhost
|
|
|
|
# wait for vhost to come back
|
|
|
|
|
|
|
|
# TO BE DONE - should be fixable w/ansible 0.9
|
|
|
|
# wait for all of the instances to return(?)
|
|
|
|
# compare the first list to the second for state info
|
|
|
|
# how to do this:
|
|
|
|
# capture output of action: virt command=info before halting guests
|
|
|
|
# compare to same command after vhost comes back
|
|
|
|
# ansible 0.9 should allow us to preserve content of two registered variables
|
|
|
|
# across multiple plays
|
|
|
|
|
|
|
|
|
2024-11-25 18:24:56 +10:00
|
|
|
---
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Find instances
|
2014-01-01 19:15:11 +00:00
|
|
|
hosts: "{{ vhost }}"
|
2013-08-12 15:47:12 +00:00
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Get list of guests
|
2016-01-06 21:33:14 +00:00
|
|
|
virt: command=list_vms
|
2013-08-12 15:47:12 +00:00
|
|
|
register: vmlist
|
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Add them to myvms_new group
|
2014-01-01 19:15:11 +00:00
|
|
|
local_action: add_host hostname={{ item }} groupname=myvms_new
|
|
|
|
with_items: "{{ vmlist.list_vms }}"
|
2013-08-12 15:47:12 +00:00
|
|
|
|
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Halt instances
|
2013-08-12 15:47:12 +00:00
|
|
|
hosts: myvms_new
|
|
|
|
user: root
|
|
|
|
serial: 1
|
|
|
|
|
|
|
|
tasks:
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Tell nagios to shush
|
2016-01-06 21:33:14 +00:00
|
|
|
nagios: action=silence host={{ inventory_hostname_short }}
|
2020-06-14 14:14:31 -07:00
|
|
|
delegate_to: noc01.iad2.fedoraproject.org
|
2013-08-12 15:47:12 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Echo-y
|
2024-12-19 11:22:24 +10:00
|
|
|
ansible.builtin.command: /sbin/halt -p
|
2013-08-12 15:47:12 +00:00
|
|
|
ignore_errors: true
|
|
|
|
# if one of them is down we don't care
|
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Wait for them to die
|
2014-01-01 19:15:11 +00:00
|
|
|
local_action: wait_for port=22 delay=30 timeout=300 state=stopped host={{ inventory_hostname }}
|