Skip to content

Instantly share code, notes, and snippets.

@nbuchwitz
Created March 18, 2020 07:25
Show Gist options
  • Save nbuchwitz/e4d721174a2bd7f71db41b4ae1ed7e55 to your computer and use it in GitHub Desktop.
Save nbuchwitz/e4d721174a2bd7f71db41b4ae1ed7e55 to your computer and use it in GitHub Desktop.
- name: schedule downtime
uri:
url: "https://{{ icinga_host }}:{{ icinga_port | default(5665) }}/v1/actions/schedule-downtime"
user: "{{ icinga_user }}"
password: "{{ icinga_password }}"
force_basic_auth: True
validate_certs: False
method: POST
headers:
Accept: "application/json"
body_format: json
body:
type: "{{ item.type }}"
filter: "{{ item.filter }}"
author: "ansible"
fixed: true
comment: "Downtime for firmware upgrade"
start_time : "{{ downtime_start }}"
end_time : "{{ downtime_end }}"
vars:
downtime_duration: 30
downtime_start: "{{ ansible_date_time.epoch }}"
downtime_end: "{{ downtime_start | int + downtime_duration * 60 }}"
loop:
- { type: "Host", filter: "host.name==\"{{system_name}}-rtr\"" }
- { type: "Service", filter: "host.name==\"{{system_name}}-rtr\"" }
delegate_to: localhost
tags:
- monitoring
- name: remove downtime
uri:
url: "https://{{ icinga_host }}:{{ icinga_port | default(5665) }}/v1/actions/remove-downtime"
user: "{{ icinga_user }}"
password: "{{ icinga_password }}"
force_basic_auth: True
validate_certs: False
method: POST
headers:
Accept: "application/json"
body_format: json
body:
type: "Downtime"
filter: "host.name==\"{{system_name}}-rtr\" && downtime.author == \"ansible\""
delegate_to: localhost
tags:
- monitoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment