community.general.datadog_downtime – Manages Datadog downtimes
Note
This plugin is part of the community.general collection (version 3.8.3).
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.datadog_downtime
.
New in version 2.0.0: of community.general
Synopsis
Manages downtimes within Datadog.
Options as described on https://docs.datadoghq.com/api/v1/downtimes/s.
Requirements
The below requirements are needed on the host that executes this module.
datadog-api-client
Python 3.6+
Parameters
Parameter |
Comments |
---|---|
The URL to the Datadog API. This value can also be set with the Default: “https://api.datadoghq.com” |
|
Your Datadog API key. |
|
Your Datadog app key. |
|
A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same “@username” notation as events. |
|
POSIX timestamp to end the downtime. If not provided, the downtime is in effect until you cancel it. |
|
The identifier of the downtime. If empty, a new downtime gets created, otherwise it is either updated or deleted depending of the To keep your playbook idempotent, you should save the identifier in a file and read it in a lookup. |
|
The ID of the monitor to mute. If not provided, the downtime applies to all monitors. |
|
A list of monitor tags to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. |
|
The For example, to have a recurring event on the first day of each month, select a type of rrule and set the Most common rrule options from the iCalendar Spec are supported. Attributes specifying the duration in |
|
A list of scopes to which the downtime applies. The resulting downtime applies to sources that matches ALL provided scopes. |
|
POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created. |
|
The designated state of the downtime. Choices:
|
|
The timezone for the downtime. |
Examples
- name: Create a downtime
register: downtime_var
community.general.datadog_downtime:
state: present
monitor_tags:
- "foo:bar"
downtime_message: "Downtime for foo:bar"
scope: "test"
api_key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
app_key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
# Lookup the id in the file and ignore errors if the file doesn't exits, so downtime gets created
id: "{{ lookup('file', inventory_hostname ~ '_downtime_id.txt', errors='ignore') }}"
- name: Save downtime id to file for later updates and idempotence
delegate_to: localhost
copy:
content: "{{ downtime.downtime.id }}"
dest: "{{ inventory_hostname ~ '_downtime_id.txt' }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The downtime returned by the API. Returned: always Sample: {“active”: true, “canceled”: null, “creator_id”: 1445416, “disabled”: false, “downtime_type”: 2, “end”: null, “id”: 1055751000, “message”: “Downtime for foo:bar”, “monitor_id”: null, “monitor_tags”: [“foo:bar”], “parent_id”: null, “recurrence”: null, “scope”: [“test”], “start”: 1607015009, “timezone”: “UTC”, “updater_id”: null} |
Authors
Datadog (@Datadog)