community.general.pagerduty_alert 模块 – 触发、确认或解决 PagerDuty 事件
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,有关详细信息,请参见 要求。
要在剧本中使用它,请指定:community.general.pagerduty_alert。
概要
- 此模块将允许您通过发送事件来触发、确认或解决 PagerDuty 事件 
要求
执行此模块的主机需要满足以下要求。
- PagerDuty API 访问 
参数
| 参数 | 注释 | 
|---|---|
| PagerDuty API 密钥(只读访问),在 PagerDuty 网站上生成。 如果  | |
| 我们希望用来运行该模块的 API 版本。 V1 在我们可以用来触发事件的选项方面更加有限。 V2 有更多变量,例如, 选项 
 | |
| 触发此事件的监视客户端的名称。 | |
| 触发此事件的监视客户端的 URL。 | |
| 负责该事件的源计算机的组件,例如  | |
| 有关事件和受影响系统的其他详细信息。 带有自定义键和值的字典。 | |
| 对于  对于  默认:  | |
| 事件的类/类型,例如  | |
| 标识应应用此  对于  对于  | |
| 您的“通用 API”服务之一的 GUID。 这是 PagerDuty 服务的“集成”选项卡上列出的“集成密钥”。 | |
| link_url 的简短描述。 | |
| 与警报相关的链接 URL。例如,网站或作业链接。 | |
| PagerDuty 唯一的子域名。已过时。它不与 PagerDuty REST v2 API 一起使用。 | |
| 将触发、确认或解决事件的 PagerDuty 服务的 ID。 如果  | |
| 您的“通用 API”服务之一的 GUID。已过时。请使用  | |
| 事件描述的有关受影响系统的状态的感知严重性。 在  选项 
 | |
| 受影响系统的唯一位置,最好是主机名或 FQDN。 在  | |
| 要发送的事件类型。 选项 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持: 完全 | 可以在  | |
| 支持: 无 | 当处于差异模式时,将返回有关已更改(或可能需要在  | 
示例
- name: Trigger an incident with just the basic options
  community.general.pagerduty_alert:
    name: companyabc
    integration_key: xxx
    api_key: yourapikey
    service_id: PDservice
    state: triggered
    desc: problem that led to this trigger
- name: Trigger an incident with more options
  community.general.pagerduty_alert:
    integration_key: xxx
    api_key: yourapikey
    service_id: PDservice
    state: triggered
    desc: problem that led to this trigger
    incident_key: somekey
    client: Sample Monitoring Service
    client_url: http://service.example.com
- name: Acknowledge an incident based on incident_key
  community.general.pagerduty_alert:
    integration_key: xxx
    api_key: yourapikey
    service_id: PDservice
    state: acknowledged
    incident_key: somekey
    desc: "some text for incident's log"
- name: Resolve an incident based on incident_key
  community.general.pagerduty_alert:
    integration_key: xxx
    api_key: yourapikey
    service_id: PDservice
    state: resolved
    incident_key: somekey
    desc: "some text for incident's log"
- name: Trigger an v2 incident with just the basic options
  community.general.pagerduty_alert:
    integration_key: xxx
    api_version: v2
    source: My Ansible Script
    state: triggered
    desc: problem that led to this trigger
- name: Trigger an v2 incident with more options
  community.general.pagerduty_alert:
    integration_key: xxx
    api_version: v2
    source: My Ansible Script
    state: triggered
    desc: problem that led to this trigger
    incident_key: somekey
    client: Sample Monitoring Service
    client_url: http://service.example.com
    component: mysql
    incident_class: ping failure
    link_url: https://pagerduty.com
    link_text: PagerDuty
- name: Acknowledge an incident based on incident_key using v2
  community.general.pagerduty_alert:
    api_version: v2
    integration_key: xxx
    incident_key: somekey
    state: acknowledged
- name: Resolve an incident based on incident_key
  community.general.pagerduty_alert:
    api_version: v2
    integration_key: xxx
    incident_key: somekey
    state: resolved
