A Notifier is an instance of a Notification type (Email, Slack, Webhook, etc.) with a name, description, and a defined configuration.
For example:
A Notification is a manifestation of the notifier; for example, when a job fails, a notification is sent using the configuration defined by the Notifier.
At a high level, the typical flow for the notification system works as follows:
/api/v2/notifiers
endpoint (either through the API or through the Tower UI)./api/v2/job_templates/n/notifiers_error
API endpoint.Notifiers assigned at certain levels will inherit notifiers defined on parent objects as such:
When a job succeeds or fails, the error or success handler will pull a list of relevant notifiers using the procedure defined above. It will then create a Notification object for each one containing relevant details about the job and then sends it to the destination (email addresses, slack channel(s), sms numbers, etc). These Notification objects are available as related resources on job types (jobs, inventory updates, project updates), and also at /api/v2/notifications
. You may also see what notifications have been sent from a notifier by examining its related resources.
If a notification fails, it will not impact the job associated to it or cause it to fail. The status of the notification can be viewed at its detail endpoint (/api/v2/notifications/<n>
).
To create a Notification Template:
Topics:
Each of these have their own configuration and behavioral semantics and testing them may need to be approached in different ways. The following sections will give as much detail as possible.
The email notification type supports a wide variety of SMTP servers and has support for TLS/SSL connections.
You must provide the following details to setup an email notification: - Username - Host - Sender email - Recipient list - Password - Port
Caution
TLS and SSL connections are mutually exclusive and should not be selected at the same time. Be sure to only select one–checking both causes the notification to silently fail.
Slack, a collaborative team communication and messaging tool, is pretty easy to configure.
You must supply the following to setup Slack notifications:
You must also invite the notification bot to join the channel(s) in question. Note that private messages are not supported.
Twilio service is an Voice and SMS automation service. Once you are signed in, you must create a phone number from which the message will be sent. You can then define a “Messaging Service” under Programmable SMS and associate the number you created before with it.
Note that you may need to verify this number or some other information before you are allowed to use it to send to any numbers. The Messaging Service does not need a status callback URL nor does it need the ability to Process inbound messages.
Under your individual (or sub) account settings, you will have API credentials. Twilio uses two credentials to determine which account an API request is coming from. The “Account SID”, which acts as a username, and the “Auth Token” which acts as a password.
To setup Twilio, provide the following details:
PagerDuty is a fairly straightforward integration. The user must first create an API Key in the pagerduty system (this is the token that is given to Tower) and then create a “Service” which provides an “Integration Key” that will also be given to Tower. The other options of note are:
towertest.pagerduty.com
and you will give the Tower API towertest
as the subdomain (not the full domain).There are several ways to integrate with HipChat. The Tower implementation uses HipChat “Integrations”. Currently you can find this at the bottom right of the main HipChat webview. From there, you will select “Build your own Integration”. After creating that, it will list the auth_token that needs to be supplied to Tower. Some other relevant details on the fields accepted by Tower for the HipChat notification type:
https://team.hipchat.com
. For a self-hosted integration, use a base URL similar to https://hipchat.yourcompany.com/
and add in appropriate Destination Channels without the #
leading them (“engineering” rahter than “#engineering”).The webhook notification type in Ansible Tower provides a simple interface to sending POSTs to a predefined web service. Tower will POST to this address using application/json content type with the data payload containing all relevant details in json format.
The parameters are pretty straightforward:
Target URL: The full URL that will be POSTed to
HTTP Headers: Headers in JSON form where the keys and values are strings. For example:
{"Authentication": "988881adc9fc3655077dc2d4d757d480b5ea0e11", "MessageType": "Test"}
The Mattermost notification type in Ansible Tower provides a simple interface to Mattermost’s messaging and collaboration workspace. The parameters that can be specified are:
The Rocket.Chat notification type in Ansible Tower provides an interface to Rocket.Chat’s collaboration and communication platform. The parameters that can be specified are:
The Tower IRC notification takes the form of an IRC bot that will connect, deliver its messages to channel(s) or individual user(s), and then disconnect. The Tower notification bot also supports SSL authentication. The Tower bot does not currently support Nickserv identification. If a channel or user does not exist or is not on-line then the Notification will not fail; the failure scenario is reserved specifically for connectivity.
Connectivity information is straightforward:
towerhost
hostname¶In /etc/tower/settings.py
, you can modify TOWER_URL_BASE='https://tower.example.com'
to change the notification hostname, replacing https://tower.example.com
with your preferred hostname. You must restart Tower services after saving your changes with ansible-tower-service restart
.
Refreshing your Tower license also changes the notification hostname. New installations of Ansible Tower 3.0 should not have to set the hostname for notifications.
TOWER_URL_BASE
¶The primary way that Tower determines how the base URL (TOWER_URL_BASE
) is defined is by looking at an incoming request and setting the server address based on that incoming request.
Tower takes settings values from the database first. If no settings values are found, Tower falls back to using the values from the settings files. If a user posts a license by navigating to the Tower host’s IP adddress, the posted license is written to the settings entry in the database.
To change the TOWER_URL_BASE
if the wrong address has been picked up, navigate to the license from the Tower Settings () Menu’s License tab using the DNS entry you wish to appear in notifications, and re-add your license.