community.general.pagerduty_alert module – Trigger, acknowledge or resolve PagerDuty incidents
Note
This module is part of the community.general collection (version 10.7.5).
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.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.pagerduty_alert.
Synopsis
- This module lets you trigger, acknowledge or resolve a PagerDuty incident by sending events. 
Requirements
The below requirements are needed on the host that executes this module.
- PagerDuty API access 
Parameters
| Parameter | Comments | 
|---|---|
| The pagerduty API key (readonly access), generated on the pagerduty site. Required if  | |
| The API version we want to use to run the module. V1 is more limited with option we can provide to trigger incident. V2 has more variables for example,  Choices: 
 | |
| The name of the monitoring client that is triggering this event. | |
| The URL of the monitoring client that is triggering this event. | |
| Component of the source machine that is responsible for the event, for example  | |
| Additional details about the event and affected system. A dictionary with custom keys and values. | |
| For  For  Default:  | |
| The class/type of the event, for example  | |
| Identifies the incident to which this  For  For  | |
| The GUID of one of your ‘Generic API’ services. This is the ‘integration key’ listed on a ‘Integrations’ tab of PagerDuty service. | |
| A short description of the  | |
| Relevant link URL to the alert. For example, the website or the job link. | |
| PagerDuty unique subdomain. Obsolete. It is not used with PagerDuty REST v2 API. | |
| ID of PagerDuty service when incidents are triggered, acknowledged or resolved. Required if  | |
| The GUID of one of your ‘Generic API’ services. Obsolete. Please use  | |
| The perceived severity of the status the event is describing with respect to the affected system. Required in case of  Choices: 
 | |
| The unique location of the affected system, preferably a hostname or FQDN. Required in case of  | |
| Type of event to be sent. Choices: 
 | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Support: full | Can run in  | |
| Support: none | Will return details on what has changed (or possibly needs changing in  | 
Examples
- 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
