AAP 2.6 Notifications and Webhooks: Slack, Teams, Email, and Custom Integrations
By Luca Berton · Published 2024-01-01 · Category: troubleshooting
Configure AAP 2.6 notifications and webhooks for Slack, Microsoft Teams, email, PagerDuty, and custom endpoints.
Notifications in AAP 2.6
AAP notifications alert teams when jobs succeed, fail, or need approval. Every job template and workflow can trigger notifications to multiple channels simultaneously.
See also: Ansible GitOps: Infrastructure as Code with Git Workflows and AAP
Notification Types
| Type | Use Case | |------|----------| | Email | Default alerting, compliance reports | | Slack | Real-time team notifications | | Microsoft Teams | Enterprise chat integration | | PagerDuty | On-call incident management | | Webhook | Custom integrations, ITSM tools | | IRC | Legacy chat systems | | Grafana | Annotation on dashboards | | Twilio | SMS alerts for critical failures | | Rocket.Chat | Self-hosted chat |
Email Notifications
Configure Email Backend
- name: Configure email notifications
ansible.builtin.uri:
url: "https://gateway.example.org/api/controller/v2/settings/jobs/"
method: PATCH
headers:
Authorization: "Bearer {{ token }}"
body_format: json
body:
EMAIL_HOST: "smtp.example.com"
EMAIL_PORT: 587
EMAIL_HOST_USER: "aap-notifications@example.com"
EMAIL_HOST_PASSWORD: "{{ vault_smtp_password }}"
EMAIL_USE_TLS: true
DEFAULT_FROM_EMAIL: "aap@example.com"
Create Email Notification Template
- name: Create email notification
ansible.platform.notification_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "Ops Team Email"
organization: "Operations"
notification_type: email
notification_configuration:
recipients:
- "ops-team@example.com"
- "automation-alerts@example.com"
subject: "[AAP] {{ job.status | upper }}: {{ job.name }}"
messages:
started:
body: |
Job "{{ job.name }}" started by {{ job.launched_by }}.
Inventory: {{ job.inventory }}
Started: {{ job.started }}
success:
body: |
Job "{{ job.name }}" completed successfully.
Duration: {{ job.elapsed }} seconds
Changed: {{ job.host_status_count_changed }} hosts
error:
body: |
Job "{{ job.name }}" FAILED.
Duration: {{ job.elapsed }} seconds
Failed hosts: {{ job.host_status_count_failed }}
View: https://gateway.example.org/#/jobs/{{ job.id }}
state: present
See also: Ansible Automation Platform 2.6 Architecture and Components: Complete Guide
Slack Integration
Create Slack Notification
- name: Create Slack notification
ansible.platform.notification_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "Slack Ops Channel"
organization: "Operations"
notification_type: slack
notification_configuration:
token: "{{ vault_slack_bot_token }}"
channels:
- "#automation-alerts"
- "#ops-team"
hex_color: "" # Auto-color based on job status
messages:
started:
body: ":rocket: *{{ job.name }}* started by {{ job.launched_by }}"
success:
body: ":white_check_mark: *{{ job.name }}* completed ({{ job.elapsed }}s) — {{ job.host_status_count_changed }} changed"
error:
body: ":x: *{{ job.name }}* FAILED — {{ job.host_status_count_failed }} hosts failed\n<https://gateway.example.org/#/jobs/{{ job.id }}|View Job>"
state: present
Microsoft Teams
Teams Webhook
- name: Create Teams notification
ansible.platform.notification_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "Teams Ops Channel"
organization: "Operations"
notification_type: webhook
notification_configuration:
url: "https://example.webhook.office.com/webhookb2/{{ teams_webhook_id }}"
headers:
Content-Type: "application/json"
messages:
error:
body: |
{
"@type": "MessageCard",
"themeColor": "FF0000",
"title": "AAP Job Failed: {{ job.name }}",
"text": "Job failed after {{ job.elapsed }} seconds. {{ job.host_status_count_failed }} hosts failed.",
"potentialAction": [{
"@type": "OpenUri",
"name": "View Job",
"targets": [{"os": "default", "uri": "https://gateway.example.org/#/jobs/{{ job.id }}"}]
}]
}
state: present
See also: AAP 2.6 Automation Mesh: Distributed Execution Across Sites and Networks
PagerDuty
- name: Create PagerDuty notification
ansible.platform.notification_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "PagerDuty Critical"
organization: "Operations"
notification_type: pagerduty
notification_configuration:
token: "{{ vault_pagerduty_api_key }}"
service_key: "{{ pagerduty_service_integration_key }}"
client_name: "AAP 2.6"
subdomain: "example"
state: present
Custom Webhooks
Generic Webhook
- name: Create custom webhook notification
ansible.platform.notification_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "ServiceNow Integration"
organization: "Operations"
notification_type: webhook
notification_configuration:
url: "https://example.service-now.com/api/now/table/incident"
http_method: POST
headers:
Content-Type: "application/json"
Authorization: "Basic {{ servicenow_auth }}"
messages:
error:
body: |
{
"short_description": "AAP Job Failed: {{ job.name }}",
"description": "Job {{ job.name }} (ID: {{ job.id }}) failed after {{ job.elapsed }}s. Failed hosts: {{ job.host_status_count_failed }}. URL: https://gateway.example.org/#/jobs/{{ job.id }}",
"urgency": "2",
"impact": "2",
"category": "Automation",
"assignment_group": "Automation Team"
}
state: present
Attach Notifications to Job Templates
- name: Attach notifications to production deploy
ansible.platform.job_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "Production Deployment"
notification_templates_started:
- "Slack Ops Channel"
notification_templates_success:
- "Slack Ops Channel"
- "Ops Team Email"
notification_templates_error:
- "Slack Ops Channel"
- "Ops Team Email"
- "PagerDuty Critical"
- "ServiceNow Integration"
state: present
Workflow Approval Notifications
- name: Configure approval notifications
ansible.platform.workflow_job_template_node:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
workflow_job_template: "Production Change"
identifier: "approval_gate"
approval_node:
name: "Production Approval Required"
description: "Approve production deployment"
timeout: 3600 # 1 hour
state: present
Incoming Webhooks (Trigger Jobs)
AAP can also receive webhooks to trigger jobs:
- name: Configure GitHub webhook trigger
ansible.platform.job_template:
controller_host: "{{ gateway_url }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "Deploy on Push"
webhook_service: github
webhook_credential: "GitHub Webhook Token"
state: present
GitHub webhook URL: https://gateway.example.org/api/controller/v2/job_templates/
Supported Webhook Sources
| Source | Service Key | Events |
|--------|------------|--------|
| GitHub | github | push, pull_request, release |
| GitLab | gitlab | push, merge_request, tag_push |
| BitBucket | bitbucket_dc | push, pull_request |
EDA-Driven Notifications
Use Event-Driven Ansible for real-time alerting:
---
- name: Monitor and alert
hosts: all
sources:
- ansible.eda.alertmanager:
host: 0.0.0.0
port: 9000
rules:
- name: Critical alert - trigger remediation and notify
condition: event.alert.labels.severity == "critical"
actions:
- run_job_template:
name: "Auto-Remediate Critical"
organization: "Operations"
- run_job_template:
name: "Notify On-Call"
organization: "Operations"
extra_vars:
alert_name: "{{ event.alert.labels.alertname }}"
instance: "{{ event.alert.labels.instance }}"
severity: "{{ event.alert.labels.severity }}"
FAQ
Can I customize notification messages per job status?
Yes. Each notification template supports separate message templates for started, success, and error states. Use Jinja2 templating with {{ job.* }} variables for dynamic content.
How do I test notifications without running a job?
Use the notification template test button in the AAP UI, or via API: POST /api/controller/v2/notification_templates/. This sends a test message to verify connectivity.
Can notifications include job output or logs?
Notification messages can reference job metadata (name, status, duration, host counts) but not the full stdout. For full logs, include a link to the job in AAP. For log forwarding, use the external logging integration (Splunk, ELK).
How do I handle notification failures?
Notification failures don't cause job failures — they're logged separately. Check Administration → Notifications for delivery status. For critical notifications, use multiple channels as redundancy.
Can I rate-limit notifications?
AAP doesn't have built-in rate limiting for notifications. Use your webhook endpoint or Slack/Teams channel settings to manage noise. For monitoring-triggered jobs, use EDA's debounce/throttle capabilities.
Conclusion
AAP 2.6's notification system integrates with every major communication and incident management platform. From Slack messages on job completion to PagerDuty alerts on failures to ServiceNow ticket creation — notifications keep teams informed and enable automated incident response workflows.
Related Articles
• AAP 2.6 Workflow Templates: Advanced Multi-Step Automation Guide • AAP 2.6 Event-Driven Ansible and Kafka Integration • AAP 2.6 Monitoring and Logging: Prometheus, Grafana, and Log Aggregation • AAP 2.6 REST API Guide: Automate the Automation Platform • AAP 2.6 Job Templates and Inventories: Complete Configuration GuideCategory: troubleshooting