Skip to content

Instantly share code, notes, and snippets.

@rfairburn
Created July 23, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfairburn/5de0b8ba5714d940a7d3 to your computer and use it in GitHub Desktop.
Save rfairburn/5de0b8ba5714d940a7d3 to your computer and use it in GitHub Desktop.
Pagerduty Example
#!jinja|yaml|gpg
pagerduty_config:
pagerduty.subdomain: c2fo
pagerduty.api_key: |
-----BEGIN PGP MESSAGE-----
<snip>
-----END PGP MESSAGE-----
pagerduty.service_key: |
-----BEGIN PGP MESSAGE-----
<snip>
-----END PGP MESSAGE-----
{% set notifications = salt['pillar.get']('pagerduty_notifications', {}) %}
{% set service_key = salt['pillar.get']('pagerduty_config:pagerduty.service_key', None) %}
{% if notifications and service_key %}
{% set details = 'Failed to apply the following states on ' ~
notifications['name'] ~ '-> ' ~
notifications['states']|join(', ') ~
'. You can look up the full details by running the following on the salt-master "salt-run jobs.lookup_jid ' ~
notifications['jid'] ~ '".' %}
pagerduty_alert:
pagerduty.create_event:
- name: Salt error on {{ notifications['name'] }}
- details: {{ details|json }}
- service_key: {{ service_key }}
- profile: pagerduty_config
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment