awx
awx copied to clipboard
AWX webhook notification not working as per document
ISSUE TYPE
- Bug Report
COMPONENT NAME
- API
- UI
SUMMARY
The ansible documentation states that for webhook one can fetch the data from the webhook payload https://docs.ansible.com/ansible-tower/latest/html/installandreference/notification_parameters_supported.html# job_metadata - (string) job metadata as a JSON string, for example: {'url': 'https://towerhost/$/jobs/playbook/13', 'traceback': '', 'status': 'running', 'started': '2019-08-07T21:46:38.362630+00:00', 'project': 'Stub project', 'playbook': 'ping.yml', 'name': 'Stub Job Template', 'limit': '', 'inventory': 'Stub Inventory', 'id': 42, 'hosts': {}, 'friendly_name': 'Job', 'finished': False, 'credential': 'Stub credential', 'created_by': 'admin'}
the same is mentioned in https://docs.ansible.com/ansible-tower/latest/html/userguide/notifications.html#webhook-payloads section 23.4.10.1
However none of it works and it throws errors in the awx-task logs that there is formatting whenever the variable "{{ job_metadata }}" is referenced the webhook payload
2021-11-17 14:18:04,728 DEBUG [5dee64b41eb64e6c80cf1b5169331bef] awx.main.dispatch task e495aca5-34ab-49ff-ab43-81cbf5e4214a starting awx.main.tasks.send_notifications([[51]]) 2021-11-17 14:18:04,751 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.dispatch task 90e99f7b-3e0e-43f1-bb75-a263d24a98ad starting awx.main.scheduler.tasks.run_task_manager([]) 2021-11-17 14:18:04,754 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Running task manager. 2021-11-17 14:18:04,761 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Starting Scheduler 2021-11-17 14:18:04,797 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Finishing Scheduler 2021-11-17 14:18:05,371 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.notifications.webhook_backend Error sending notification webhook: 400 2021-11-17 14:18:05,373 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.tasks Send Notification Failed Error sending notification webhook: 4002021-11-17 14:18:04,728 DEBUG [5dee64b41eb64e6c80cf1b5169331bef] awx.main.dispatch task e495aca5-34ab-49ff-ab43-81cbf5e4214a starting awx.main.tasks.send_notifications([[51]]) 2021-11-17 14:18:04,751 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.dispatch task 90e99f7b-3e0e-43f1-bb75-a263d24a98ad starting awx.main.scheduler.tasks.run_task_manager([]) 2021-11-17 14:18:04,754 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Running task manager. 2021-11-17 14:18:04,761 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Starting Scheduler 2021-11-17 14:18:04,797 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Finishing Scheduler 2021-11-17 14:18:05,371 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.notifications.webhook_backend Error sending notification webhook: 400 2021-11-17 14:18:05,373 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.tasks Send Notification Failed Error sending notification webhook: 400 Traceback (most recent call last): File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 354, in send_notifications sent = notification.notification_template.send(notification.subject, notification.body) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/models/notifications.py", line 185, in send return backend_obj.send_messages([notification_obj]) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/notifications/webhook_backend.py", line 81, in send_messages raise Exception(smart_text(("Error sending notification webhook: {}").format(r.status_code))) Exception: Error sending notification webhook: 400 Traceback (most recent call last): File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 354, in send_notifications sent = notification.notification_template.send(notification.subject, notification.body) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/models/notifications.py", line 185, in send return backend_obj.send_messages([notification_obj]) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/notifications/webhook_backend.py", line 81, in send_messages raise Exception(smart_text(("Error sending notification webhook: {}").format(r.status_code))) Exception: Error sending notification webhook: 400
ENVIRONMENT
- AWX version: 19.4.0
- AWX install method: operator
- AWX deployment target: minikube
- Operating System: redhat enterprise linux 7
- Web Browser: google chrome
STEPS TO REPRODUCE
Please try and setup a incoming webhook in my case I am using microsoft teams Now in AWX please setup a notification and in the success job message use the below payload The payload I am using to send the notification { "@type": "MessageCard", "@context": "http://schema.org/extensions", "summary": "Job Success: {{ job.name }}", "title": "Job Success: {{ job.name }}", "themeColor": "008000", "sections": [ { "title": "Details", "facts": [ { "name": "Start date", "value": "{{ job.started }}" }, { "name": "End date", "value": "{{ job.finished }}" }, { "name": "Host", "value": "{{ job_metadata }}" }, { "name": "Executed by", "value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}" } ] } ], "potentialAction": [ { "@context": "http://schema.org", "@type": "ViewAction", "name": "View on AWX", "target": [ "{{ url }}" ] } ] }
EXPECTED RESULTS
{'url': 'https://towerhost/$/jobs/playbook/13', 'traceback': '', 'status': 'running', 'started': '2019-08-07T21:46:38.362630+00:00', 'project': 'Stub project', 'playbook': 'ping.yml', 'name': 'Stub Job Template', 'limit': '', 'inventory': 'Stub Inventory', 'id': 42, 'hosts': {}, 'friendly_name': 'Job', 'finished': False, 'credential': 'Stub credential', 'created_by': 'admin'}
ACTUAL RESULTS
2021-11-17 14:18:04,728 DEBUG [5dee64b41eb64e6c80cf1b5169331bef] awx.main.dispatch task e495aca5-34ab-49ff-ab43-81cbf5e4214a starting awx.main.tasks.send_notifications([[51]]) 2021-11-17 14:18:04,751 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.dispatch task 90e99f7b-3e0e-43f1-bb75-a263d24a98ad starting awx.main.scheduler.tasks.run_task_manager([]) 2021-11-17 14:18:04,754 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Running task manager. 2021-11-17 14:18:04,761 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Starting Scheduler 2021-11-17 14:18:04,797 DEBUG [9ea7c963e3de4ffba247a056ea4e99ed] awx.main.scheduler Finishing Scheduler 2021-11-17 14:18:05,371 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.notifications.webhook_backend Error sending notification webhook: 400 2021-11-17 14:18:05,373 ERROR [5dee64b41eb64e6c80cf1b5169331bef] awx.main.tasks Send Notification Failed Error sending notification webhook: 400 Traceback (most recent call last): File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 354, in send_notifications sent = notification.notification_template.send(notification.subject, notification.body) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/models/notifications.py", line 185, in send return backend_obj.send_messages([notification_obj]) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/notifications/webhook_backend.py", line 81, in send_messages raise Exception(smart_text(_("Error sending notification webhook: {}").format(r.status_code))) Exception: Error sending notification webhook: 400
ADDITIONAL INFORMATION
NA
@AbhinitMallick Can you try asking your question on the mailing list?
Can you try asking your question on the mailing list?
@chrismeyersfsu can you please come again , I honestly didnt get you mate , what exactly you mean
https://groups.google.com/g/awx-project
It looks like your teams server is responding with a 400. This isn't necessarily an AWX issue. Maybe someone on the mailing list has experienced this integration pain and can point you in the right direction.