1
0
Fork 0
forked from infra/ansible
ansible/playbooks/host_reboot.yml

56 lines
2 KiB
YAML
Raw Permalink Normal View History

# requires --extra-vars="target=hostspec"
---
- name: Reboot hosts
hosts: "{{ target }}"
gather_facts: false
user: root
serial: 1
# We need the Zabbix API key from private
vars_files:
- "/srv/private/ansible/vars.yml"
tasks:
- name: Tell nagios to shush
nagios: action=downtime minutes=60 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
delegate_to: noc01.rdu3.fedoraproject.org
ignore_errors: true
2012-12-12 04:43:49 +00:00
- name: Disable target in Zabbix
community.zabbix.zabbix_host:
host_name: "{{ target }}"
status: disabled
vars:
# We can't put the zabbix vars in a block or it'll reboot the host running the play (i.e batcave)
# so we'll have to duplicate them below
ansible_zabbix_auth_key: "{{ zabbix_auth_key }}"
ansible_network_os: "{{ zabbix_network_os }}"
ansible_connection: "{{ zabbix_connection }}"
ansible_httpapi_port: "{{ zabbix_httpapi_port }}"
ansible_httpapi_use_ssl: "{{ zabbix_httpapi_use_ssl }}"
ansible_httpapi_validate_certs: "{{ zabbix_httpapi_validate_certs }}"
ansible_host: "{{ zabbix_server }}"
ansible_zabbix_url_path: "{{ zabbix_url_path }}"
- name: Reboot the host
ansible.builtin.reboot:
reboot_timeout=1800
- name: Tell nagios to unshush
nagios: action=unsilence service=host host={{ inventory_hostname_short }}{{ env_suffix }}
delegate_to: noc01.rdu3.fedoraproject.org
2014-09-30 16:48:50 +00:00
ignore_errors: true
- name: Enable target in Zabbix
community.zabbix.zabbix_host:
host_name: "{{ target }}"
status: enabled
vars:
ansible_zabbix_auth_key: "{{ zabbix_auth_key }}"
ansible_network_os: "{{ zabbix_network_os }}"
ansible_connection: "{{ zabbix_connection }}"
ansible_httpapi_port: "{{ zabbix_httpapi_port }}"
ansible_httpapi_use_ssl: "{{ zabbix_httpapi_use_ssl }}"
ansible_httpapi_validate_certs: "{{ zabbix_httpapi_validate_certs }}"
ansible_host: "{{ zabbix_server }}"
ansible_zabbix_url_path: "{{ zabbix_url_path }}"