Ansible is a powerful automation engine that makes systems and applications simple to deploy. No custom scripting or custom code. No agents. All using an automation language that’s easy for anyone to understand and learn. Just get in, get it done, and make some time for other strategic projects.
The PagerDuty Ansible module allows you to create and list ongoing maintenance windows for services on your PagerDuty account, trigger, acknowledge or resolve PagerDuty incidents, manage user accounts and send change events.
If you are using Ansible 1.8 or higher, we highly suggest using an API Key and requester ID instead of using a username and password. Please note, you must be a PagerDuty Admin or the Account Owner to create the API token.
- From the Apps & Add-Ons menu on the right of the PagerDuty web app, select API Access.
- On your API Access page, click the +Create New API Key button.
- In the dialog that pops up, you’ll be prompted to enter a Description for your key. You will also have the option to create the key as Read-only; leaving this box unchecked will create a full access key.
- Once you have filled in your options, click Create Key.
- Once you click Create Key, you will see a dialog displaying your key and confirming the options you filled in on the previous step. Make sure to copy this key and keep it in a safe place for later use, as you will not have access to the key after this step. If you lose a key that you created previously and need access to it again, you should remove the key and create a new one. Click Close once you have successfully copied your key.
- In the top right corner, click on your avatar and select My Profile.
- In the URL bar, the last set of 7 characters after the /, starting with the letter P, is your requester ID.
If you need to find the service ID to create a maintenance window, here’s how you would do so:
- Click on the Services tab and then click on Service Directory.
- Find the service and click on the name.
- In the URL, the last set of 7 characters after the /, starting with the letter P, is the service ID.
In your Ansible playbook
Use the API Key generated in PagerDuty as the
token parameter, and the service ID (where applicable) as the
requester_id parameter, with the example tasks listed for the following actions: