ansible/playbooks/host-reboot.yml

31 lines
942 B
YAML
Raw Normal View History

# requires --extra-vars="hosts=hostspec"
- name: reboot hosts
hosts: $hosts
user: root
tasks:
2012-12-12 04:36:27 +00:00
- name: see if it needs to be rebooted
2012-12-12 04:39:28 +00:00
action: command /usr/local/bin/needs-reboot.py
2012-12-12 04:36:27 +00:00
register: needsreboot
2012-12-12 21:31:56 +00:00
- name: tell nagios to shush
action: nagios action=silence host=${inventory_hostname_short}
delegate_to: noc01.phx2.fedoraproject.org
2012-12-12 21:45:30 +00:00
only_if: "'${needsreboot.stdout}'.find('yes') != -1"
2012-12-12 04:43:49 +00:00
2012-12-11 22:09:42 +00:00
- name: reboot the host
2012-12-12 04:43:49 +00:00
action: command /sbin/reboot
2012-12-12 04:39:28 +00:00
only_if: "'${needsreboot.stdout}'.find('yes') != -1"
2012-12-11 22:09:42 +00:00
- name: wait for host to come back - up to 6 minutes
local_action: wait_for host=${inventory_hostname} port=22 delay=10 timeout=420
2012-12-12 04:39:28 +00:00
only_if: "'${needsreboot.stdout}'.find('yes') != -1"
2012-12-12 21:45:30 +00:00
- name: tell nagios to shush
action: nagios action=unsilence host=${inventory_hostname_short}
2012-12-12 21:45:30 +00:00
delegate_to: noc01.phx2.fedoraproject.org
only_if: "'${needsreboot.stdout}'.find('yes') != -1"
2012-12-12 04:43:49 +00:00