Implement communication with Nagios when rebooting boxes
One step closer to that full automation goal
This commit is contained in:
parent
000d711d7a
commit
4b626dc6be
@ -2,12 +2,34 @@
|
|||||||
# vim:ft=ansible:
|
# vim:ft=ansible:
|
||||||
---
|
---
|
||||||
- hosts: tags_autoreboot
|
- hosts: tags_autoreboot
|
||||||
|
module_defaults:
|
||||||
|
nagios:
|
||||||
|
author: Ansible
|
||||||
|
action: downtime
|
||||||
|
cmdfile: /data/nagios/var/rw/nagios.cmd
|
||||||
|
comment: "Ansible tags_autoreboot task"
|
||||||
|
host: "{{ inventory_hostname }}"
|
||||||
|
minutes: 10
|
||||||
serial: 1
|
serial: 1
|
||||||
tasks:
|
tasks:
|
||||||
- name: check for reboot-required
|
- name: check for reboot-required
|
||||||
stat: path=/var/run/reboot-required
|
stat: path=/var/run/reboot-required
|
||||||
register: s
|
register: s
|
||||||
- name: reboot
|
- name: reboot
|
||||||
reboot: reboot_timeout=300
|
block:
|
||||||
|
- name: attempt to schedule downtime
|
||||||
|
block:
|
||||||
|
- name: register nagios host downtime
|
||||||
|
nagios:
|
||||||
|
service: host
|
||||||
|
delegate_to: web3.dallas.mgmt.desu.ltd
|
||||||
|
- name: register nagios service downtime
|
||||||
|
nagios:
|
||||||
|
service: all
|
||||||
|
delegate_to: web3.dallas.mgmt.desu.ltd
|
||||||
|
rescue:
|
||||||
|
- name: notify of failure to reboot
|
||||||
|
debug: msg="Miscellaneous failure when scheduling downtime"
|
||||||
|
- name: reboot
|
||||||
|
reboot: reboot_timeout=300
|
||||||
when: s.stat.exists
|
when: s.stat.exists
|
||||||
become: yes
|
|
||||||
|
Loading…
Reference in New Issue
Block a user