community.general.pagerduty 模块 – 创建 PagerDuty 维护窗口

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。 您需要进一步的要求才能使用此模块,有关详细信息,请参见 要求

要在剧本中使用它,请指定:community.general.pagerduty

概要

  • 此模块将允许您创建 PagerDuty 维护窗口

要求

执行此模块的主机上需要满足以下要求。

  • PagerDuty API 访问

参数

参数

注释

desc

字符串

维护窗口的简短描述。

默认值: "由 Ansible 创建"

hours

字符串

维护窗口的长度(以小时为单位)。

默认值: "1"

minutes

字符串

维护窗口的分钟数(将添加到小时数中)。

默认值: "0"

name

字符串

PagerDuty 唯一子域。已过时。它不与 PagerDuty REST v2 API 一起使用。

requester_id

字符串

发出请求的用户的 ID。仅在创建 maintenance_window 时需要。

service

别名: services

列表 / 元素=字符串

PagerDuty 服务 ID 的逗号分隔列表。

state

字符串 / 必需

创建维护窗口或获取正在进行的窗口列表。

选择

  • "running"

  • "started"

  • "ongoing"

  • "absent"

token

字符串 / 必需

在 pagerduty 站点上生成的 pagerduty 令牌。它用于授权。

user

字符串

PagerDuty 用户 ID。已过时。请使用 token 进行授权。

validate_certs

布尔值

如果 false,则不会验证 SSL 证书。 这仅应在个人控制的站点上使用自签名证书。

选择

  • false

  • true ← (默认)

window_id

字符串

维护窗口的 ID。仅在删除维护窗口时需要。

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:

在 diff 模式下,将返回有关已更改(或可能需要在 check_mode 中进行更改)的详细信息。

示例

- name: List ongoing maintenance windows using a token
  community.general.pagerduty:
    name: companyabc
    token: xxxxxxxxxxxxxx
    state: ongoing

- name: Create a 1 hour maintenance window for service FOO123
  community.general.pagerduty:
    name: companyabc
    user: [email protected]
    token: yourtoken
    state: running
    service: FOO123

- name: Create a 5 minute maintenance window for service FOO123
  community.general.pagerduty:
    name: companyabc
    token: xxxxxxxxxxxxxx
    hours: 0
    minutes: 5
    state: running
    service: FOO123


- name: Create a 4 hour maintenance window for service FOO123 with the description "deployment"
  community.general.pagerduty:
    name: companyabc
    user: [email protected]
    state: running
    service: FOO123
    hours: 4
    desc: deployment
  register: pd_window

- name: Delete the previous maintenance window
  community.general.pagerduty:
    name: companyabc
    user: [email protected]
    state: absent
    window_id: '{{ pd_window.result.maintenance_window.id }}'

# Delete a maintenance window from a separate playbook than its creation,
# and if it is the only existing maintenance window
- name: Check
  community.general.pagerduty:
    requester_id: XXXXXXX
    token: yourtoken
    state: ongoing
  register: pd_window

- name: Delete
  community.general.pagerduty:
    requester_id: XXXXXXX
    token: yourtoken
    state: absent
    window_id: "{{ pd_window.result.maintenance_windows[0].id }}"

作者

  • Andrew Newdigate (@suprememoocow)

  • Dylan Silva (@thaumos)

  • Justin Johns

  • Bruce Pennypacker (@bpennypacker)