awx.awx.notification_template module – create, update, or destroy Automation Platform Controller notification.
Note
This module is part of the awx.awx collection (version 24.6.1).
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 awx.awx
.
To use it in a playbook, specify: awx.awx.notification_template
.
Synopsis
Create, update, or destroy Automation Platform Controller notifications. See https://www.ansible.com/tower for an overview.
Aliases: tower_notification, tower_notification_template
Parameters
Parameter |
Comments |
---|---|
Path to the controller config file. If provided, the other locations for config files will not be considered. |
|
URL to your Automation Platform Controller instance. If value not set, will try environment variable If value not specified by any means, the value of |
|
The OAuth token to use. This value can be in one of two formats. A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX) A dictionary structure as returned by the token module. If value not set, will try environment variable |
|
Password for your controller instance. If value not set, will try environment variable |
|
Username for your controller instance. If value not set, will try environment variable |
|
Name or id to copy the notification from. This will copy an existing notification and change any parameters supplied. The new notification name will be the one provided in the name parameter. The organization parameter is not used in this, to facilitate copy from one organization to another. Provide the id or use the lookup plugin to provide the id if multiple notifications share the same name. |
|
The description of the notification. |
|
Optional custom messages for notification template. |
|
The name of the notification. |
|
Setting this option will change the existing name (looked up via the name field. |
|
The notification configuration file. Note providing this field would disable all notification-configuration-related fields. username (the mail server username) sender (the sender email address) recipients (the recipients email addresses) use_tls (the TLS trigger) host (the mail server host) use_ssl (the SSL trigger) password (the mail server password) port (the mail server port) channels (the destination Slack channels) token (the access token) account_token (the Twillio account token) from_number (the source phone number) to_numbers (the destination phone numbers) account_sid (the Twillio account SID) subdomain (the PagerDuty subdomain) service_key (the PagerDuty service/integration API key) client_name (the PagerDuty client identifier) message_from (the label to be shown with the notification) color (the notification color) notify (the notify channel trigger) url (the target URL) headers (the HTTP headers as JSON string) server (the IRC server address) nickname (the IRC nickname) targets (the destination channels or users) |
|
The type of notification to be sent. Choices:
|
|
The organization name, ID, or named URL the notification belongs to. |
|
Specify the timeout Ansible should use in requests to the controller host. Defaults to 10s, but this is handled by the shared module_utils code |
|
Desired state of the resource. Choices:
|
|
Whether to allow insecure connections to AWX. If This should only be used on personally controlled sites using self-signed certificates. If value not set, will try environment variable Choices:
|
Notes
Note
If no config_file is provided we will attempt to use the tower-cli library defaults to find your host information.
config_file should be in the following format host=hostname username=username password=password
Examples
- name: Add Slack notification with custom messages
notification_template:
name: slack notification
organization: Default
notification_type: slack
notification_configuration:
channels:
- general
token: cefda9e2be1f21d11cdd9452f5b7f97fda977f42
messages:
started:
message: "{{ '{{ job_friendly_name }}{{ job.id }} started' }}"
success:
message: "{{ '{{ job_friendly_name }} completed in {{ job.elapsed }} seconds' }}"
error:
message: "{{ '{{ job_friendly_name }} FAILED! Please look at {{ job.url }}' }}"
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Add webhook notification
notification_template:
name: webhook notification
notification_type: webhook
notification_configuration:
url: http://www.example.com/hook
headers:
X-Custom-Header: value123
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Add email notification
notification_template:
name: email notification
notification_type: email
notification_configuration:
username: user
password: s3cr3t
sender: [email protected]
recipients:
- [email protected]
host: smtp.example.com
port: 25
use_tls: no
use_ssl: no
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Add twilio notification
notification_template:
name: twilio notification
notification_type: twilio
notification_configuration:
account_token: a_token
account_sid: a_sid
from_number: '+15551112222'
to_numbers:
- '+15553334444'
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Add PagerDuty notification
notification_template:
name: pagerduty notification
notification_type: pagerduty
notification_configuration:
token: a_token
subdomain: sub
client_name: client
service_key: a_key
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Add IRC notification
notification_template:
name: irc notification
notification_type: irc
notification_configuration:
nickname: controller
password: s3cr3t
targets:
- user1
port: 8080
server: irc.example.com
use_ssl: no
state: present
controller_config_file: "~/tower_cli.cfg"
- name: Delete notification
notification_template:
name: old notification
state: absent
controller_config_file: "~/tower_cli.cfg"
- name: Copy webhook notification
notification_template:
name: foo notification
copy_from: email notification
organization: Foo