community.general.icinga2_downtime module – Manages Icinga 2 downtimes
Note
This module is part of the community.general collection (version 12.4.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.icinga2_downtime.
New in community.general 12.4.0
Synopsis
Manages downtimes in Icinga 2 through its REST API.
Options as described at https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#schedule-downtime.
Parameters
Parameter |
Comments |
|---|---|
Whether downtimes should be created for all services of the matched host objects. If omitted, Icinga 2 does not create downtimes for all services of the matched host objects by default. Choices:
|
|
Name of the author. Default: |
|
CA certificates bundle to use to verify the Icinga 2 server certificate. |
|
Schedule child downtimes. Choices:
|
|
PEM formatted certificate chain file to be used for SSL client authentication. This file can also include the key as well, and if the key is included, |
|
PEM formatted file that contains your private key to be used for SSL client authentication. If |
|
A descriptive comment. Default: |
|
Duration of the downtime. Required in case of a flexible downtime. |
|
End time of the downtime as UNIX timestamp. |
|
Filter expression limiting the objects to operate on. |
|
Variable names and values used in the filter expression. |
|
Whether the downtime is fixed or flexible. If omitted, Icinga 2 creates a fixed downtime by default. Choices:
|
|
If Choices:
|
|
Credentials specified with Choices:
|
|
Header to identify as, generally appears in web server logs. Default: |
|
Name of the downtime object. This option has no effect for states other than |
|
Use Use Choices:
|
|
Start time of the downtime as UNIX timestamp. |
|
State of the downtime. Choices:
|
|
How long to wait for the server to send data before giving up. Default: |
|
Name of the downtime trigger. |
|
URL of the Icinga 2 REST API. |
|
The password for use in HTTP basic authentication. If the |
|
The username for use in HTTP basic authentication. This parameter can be used without |
|
Use GSSAPI to perform the authentication, typically this is for Kerberos or Kerberos through Negotiate authentication. Requires the Python library gssapi to be installed. Credentials for GSSAPI can be specified with NTLM authentication is not supported even if the GSSAPI mech for NTLM has been installed. Choices:
|
|
If Choices:
|
|
If This should only be used on personally controlled sites using self-signed certificates. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: none In case of a complex filter expression, it may become very complex to decide whether downtime creation or removal will succeed and trigger a change. |
Can run in |
|
Support: none |
Returns details on what has changed (or possibly needs changing in |
Examples
- name: Schedule a host downtime
community.general.icinga2_downtime:
url: "https://icinga2.example.com:5665"
url_username: icingadmin
url_password: secret
state: present
author: Ansible
comment: Scheduled downtime for test purposes.
all_services: true
start_time: "{{ downtime_start_time }}"
end_time: "{{ downtime_end_time }}"
duration: "{{ downtime_duration }}"
fixed: true
object_type: Host
filter: host.name=="host.example.com"
delegate_to: localhost
register: icinga2_downtime_response
vars:
downtime_start_time: "{{ ansible_date_time['epoch'] | int }}"
downtime_end_time: "{{ downtime_start_time | int + 3600 }}"
downtime_duration: "{{ downtime_end_time | int - downtime_start_time | int }}"
- name: Remove scheduled host downtime
community.general.icinga2_downtime:
url: "https://icinga2.example.com:5665"
url_username: icingadmin
url_password: secret
state: absent
author: Ansible
object_type: Downtime
name: "{{ icinga2_downtime_response.results[0].name }}"
delegate_to: localhost
when: icinga2_downtime_response.results | default([]) | length > 0
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Error message as JSON dictionary returned from the Icinga 2 API. Returned: if downtime scheduling or removal did not succeed Sample: |
|
Results of downtime scheduling or removal Returned: success Sample: |
|
Success or error code of downtime scheduling. Returned: always Sample: |
|
Legacy id of the downtime object. Returned: if a downtime was scheduled successfully Sample: |
|
Name of the downtime object. Returned: if a downtime was scheduled successfully Sample: |
|
Human-readable message describing the result of downtime scheduling. Returned: always Sample: |