community.general.pagerduty_alert (8.5.0) — module

Trigger, acknowledge or resolve PagerDuty incidents

Authors: Amanpreet Singh (@ApsOps), Xiao Shen (@xshen1)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

This module will let you trigger, acknowledge or resolve a PagerDuty incident by sending events


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Resolve an incident based on incident_key
  community.general.pagerduty_alert:
    api_version: v2
    integration_key: xxx
    incident_key: somekey
    state: resolved

Inputs

    
desc:
    default: Created via Ansible
    description:
    - For O(state=triggered) - Required. Short description of the problem that led to
      this trigger. This field (or a truncated version) will be used when generating phone
      calls, SMS messages and alert emails. It will also appear on the incidents tables
      in the PagerDuty UI. The maximum length is 1024 characters.
    - For O(state=acknowledged) or O(state=resolved) - Text that will appear in the incident's
      log associated with this event.
    required: false
    type: str

name:
    description:
    - PagerDuty unique subdomain. Obsolete. It is not used with PagerDuty REST v2 API.
    type: str

state:
    choices:
    - triggered
    - acknowledged
    - resolved
    description:
    - Type of event to be sent.
    required: true
    type: str

client:
    description:
    - The name of the monitoring client that is triggering this event.
    required: false
    type: str

source:
    description:
    - The unique location of the affected system, preferably a hostname or FQDN.
    - Required in case of O(state=trigger) and O(api_version=v2).
    required: false
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

api_key:
    description:
    - The pagerduty API key (readonly access), generated on the pagerduty site.
    - Required if O(api_version=v1).
    type: str

link_url:
    description:
    - Relevant link url to the alert. For example, the website or the job link.
    required: false
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

severity:
    choices:
    - critical
    - warning
    - error
    - info
    default: critical
    description:
    - The perceived severity of the status the event is describing with respect to the
      affected system.
    - Required in case of O(state=trigger) and O(api_version=v2).
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

component:
    description:
    - Component of the source machine that is responsible for the event, for example C(mysql)
      or C(eth0).
    required: false
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

link_text:
    description:
    - A short description of the link_url.
    required: false
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

client_url:
    description:
    - The URL of the monitoring client that is triggering this event.
    required: false
    type: str

service_id:
    description:
    - ID of PagerDuty service when incidents will be triggered, acknowledged or resolved.
    - Required if O(api_version=v1).
    type: str

api_version:
    choices:
    - v1
    - v2
    default: v1
    description:
    - 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, O(severity), O(source), O(custom_details), etc.
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

service_key:
    description:
    - The GUID of one of your 'Generic API' services. Obsolete. Please use O(integration_key).
    type: str

incident_key:
    description:
    - Identifies the incident to which this O(state) should be applied.
    - For O(state=triggered) - If there's no open (i.e. unresolved) incident with this
      key, a new one will be created. If there's already an open incident with a matching
      key, this event will be appended to that incident's log. The event key provides
      an easy way to 'de-dup' problem reports. If no O(incident_key) is provided, then
      it will be generated by PagerDuty.
    - For O(state=acknowledged) or O(state=resolved) - This should be the incident_key
      you received back when the incident was first opened by a trigger event. Acknowledge
      events referencing resolved or nonexistent incidents will be discarded.
    required: false
    type: str

custom_details:
    description:
    - Additional details about the event and affected system.
    - A dictionary with custom keys and values.
    required: false
    type: dict
    version_added: 7.4.0
    version_added_collection: community.general

incident_class:
    description:
    - The class/type of the event, for example C(ping failure) or C(cpu load).
    required: false
    type: str
    version_added: 7.4.0
    version_added_collection: community.general

integration_key:
    description:
    - The GUID of one of your 'Generic API' services.
    - This is the 'integration key' listed on a 'Integrations' tab of PagerDuty service.
    type: str