From 143852c4e85080425bd141061434631b187d1ca3 Mon Sep 17 00:00:00 2001 From: Salt Date: Mon, 18 Apr 2022 11:15:16 -0500 Subject: [PATCH] Move tags_autoreboot into cleanup.yml This avoids it being picked up during site_pre --- playbooks/cleanup.yml | 33 ++++++++++++++++++++++++++++++++ playbooks/tags_autoreboot.yml | 36 ----------------------------------- 2 files changed, 33 insertions(+), 36 deletions(-) delete mode 100755 playbooks/tags_autoreboot.yml diff --git a/playbooks/cleanup.yml b/playbooks/cleanup.yml index a477bfc..38128df 100755 --- a/playbooks/cleanup.yml +++ b/playbooks/cleanup.yml @@ -7,3 +7,36 @@ - name: touch ansible timestamp file file: path=/var/lib/ansible-last-run state=touch mode='0644' changed_when: no +- hosts: tags_autoreboot + gather_facts: no + 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 + tasks: + - name: check for reboot-required + stat: path=/var/run/reboot-required + register: s + - name: reboot + 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=600 + when: s.stat.exists diff --git a/playbooks/tags_autoreboot.yml b/playbooks/tags_autoreboot.yml deleted file mode 100755 index 20d9fae..0000000 --- a/playbooks/tags_autoreboot.yml +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env ansible-playbook -# vim:ft=ansible: ---- -- hosts: tags_autoreboot - gather_facts: no - 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 - tasks: - - name: check for reboot-required - stat: path=/var/run/reboot-required - register: s - - name: reboot - 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=600 - when: s.stat.exists