community.general.datadog_downtime 模块 – 管理 Datadog 停机时间
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定: community.general.datadog_downtime。
community.general 2.0.0 中的新增功能
概要
- 管理 Datadog 中的停机时间。 
要求
执行此模块的主机需要以下要求。
- datadog-api-client 
- Python 3.6+ 
参数
| 参数 | 注释 | 
|---|---|
| Datadog API 的 URL。 此值也可以使用  默认值:  | |
| 您的 Datadog API 密钥。 | |
| 您的 Datadog 应用密钥。 | |
| 要包含在此停机时间通知中的消息。 可以使用与事件相同的“@用户名”表示法将电子邮件通知发送给特定用户。 | |
| 结束停机时间的 POSIX 时间戳。如果未提供,则停机时间将一直有效,直到您取消它。 | |
| 要静默的监控器的 ID。如果未提供,则停机时间适用于所有监控器。 | |
| 停机时间适用的监控器标签列表。 生成的停机时间适用于与所有提供的监控器标签匹配的监控器。 | |
| 定义重复事件的  例如,要每个月的第一天都有一个重复事件,请选择一种 rrule 类型并将  支持 iCalendar 规范中最常见的 rrule 选项。 不支持在  | |
| 停机时间适用的范围列表。 生成的停机时间适用于与所有提供的范围匹配的来源。 | |
| 开始停机时间的 POSIX 时间戳。如果未提供,则停机时间在其创建时开始。 | |
| 停机时间的指定状态。 选择 
 | |
| 停机时间的时区。 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:不支持 | 可以在  | |
| 支持:不支持 | 在差异模式下,将返回有关已更改内容(或可能需要在  | 
示例
- 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' }}"
返回值
常见的返回值已在 此处 记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| API 返回的停机时间。 返回:始终 示例:  | 
