Webhook notification setup

269 views
Skip to first unread message

Vibin K Madampath

unread,
May 12, 2023, 2:45:12 AM5/12/23
to AWX Project
Hello Team,

I'm looking for some guidance on setting up webhook notification in AWX. Haven't found any relevant documentation or examples online.

My requirement is to create an incident when a job is failed in AWX, there are two mandatory fields required by the incident creation API ie; short_description & assignment_group.

I tried passing this info as variables via http headers but gets an error (code 417). Also, dictionary is not allowed under http headers.

I did not find any other way to pass this info to the API, has anyone figured this out ?

Any help is much appreciated. 

AWX Version: 21.5.0 hosted on K8s Cluster.

Regards,
Vibin

Vibin K Madampath

unread,
May 16, 2023, 2:07:48 AM5/16/23
to AWX Project
Hello Team,

Any input is highly appreciated.

Regards,
Vibin

AWX Project

unread,
May 17, 2023, 3:00:59 PM5/17/23
to AWX Project
Can you clarify what you are attempting to do?
Are you using a web hook notification template inside AWX and trying to send an HTTP request to an incident management system on job failure?
If so, here is the documentation around doing that: https://docs.ansible.com/automation-controller/latest/html/userguide/webhooks.html#payload-output

-The AWX Team

Vibin K Madampath

unread,
May 17, 2023, 3:29:18 PM5/17/23
to AWX Project
Hello Team, 

Thanks for the response.

Yes, you are spot on. So if I understand correctly, I should be able to send the payload using awx_webhook_payload variable. But where should I declare that variable ? Because in the webhook notification template, there's only option to mention HTTP HEADERS. 

I tried passing variables like below in the HTTP HEADERS section but it didn't allow dictionary type input.

  extra_vars: {
     description: test,
     group: abc
      }
}

Does replacing extra_vars with awx_webhook_payload in the above declaration work ?

Or did I get it completely wrong ?

Regards,
Vibin

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/7945a545-ff73-4ad7-bb25-5be7a60bee03n%40googlegroups.com.

Vibin K Madampath

unread,
May 20, 2023, 1:23:16 AM5/20/23
to AWX Project
Hi Team,

I tried multiple ways but couldn't figure out how to send payload to the webhook endpoint.

Those which doesn't need any input works fine.

Please provide your comments.

Regards,
Vibin

Vibin K Madampath

unread,
May 22, 2023, 10:19:08 AM5/22/23
to AWX Project
Hello Team,

I was unable to find the awx_webhook_payload under extra_vars of the job template as mentioned in the url. 

I tried passing it manually using variables section of the job template but nothing worked.

Appreciate if you could point me in the right direction.

Regards,
Vibin

Alex Shishko

unread,
May 22, 2023, 10:36:17 AM5/22/23
to awx-p...@googlegroups.com
Hello. Watch this video for webhook variables understanding
https://youtu.be/LVbFyjgwvQY

You have to enable notification for your template with webhook
image.png
For enabling mail notification watch this video:
https://youtu.be/tVoPkYfFgS4


пт, 12 мая 2023 г. в 09:45, Vibin K Madampath <mm.v...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.

Vibin K Madampath

unread,
May 23, 2023, 10:00:29 AM5/23/23
to AWX Project
Hello Team,


I'm not looking for AWX integration with Github webhook.

Just to be very clear, am trying to create a notification template of type Webhook. I need to send couple of inputs to the target URL but unable to do so. Looking for some guidance on how to accomplish this.

Please see the screenshot below and advise.

20230523_192138.jpg

AWX Project

unread,
May 24, 2023, 2:47:18 PM5/24/23
to AWX Project
do you see any errors or messages related to that target URL in your k8s logs (either on task container or web containers)?

AWX Team

Vibin

unread,
May 25, 2023, 5:06:52 AM5/25/23
to AWX Project
Yes, please see the messages pasted below. 

"POST /api/v2/notification_templates/9/test/ HTTP/1.1" 202 598 "https://awx.abc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" 

POST /api/v2/notification_templates/9/test/ => generated 598 bytes in 207 msecs (HTTP/1.1 202) 15 headers in 620 bytes (1 switches on core 0)

DEBUG    [5ba28775cf584172af70e6901e00fb39] awx.analytics.performance request: <WSGIRequest: GET '/api/v2/notifications/3873/'>, response_time: 0.219s

"GET /api/v2/notifications/3873/ HTTP/1.1" 200 852 "https://awx.abc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" 

GET /api/v2/notifications/3873/ => generated 852 bytes in 222 msecs (HTTP/1.1 200) 14 headers in 580 bytes (1 switches on core 0)


    {
      "id": 3873,
      "type": "notification",
      "url": "/api/v2/notifications/3873/",
      "related": {
        "notification_template": "/api/v2/notification_templates/9/"
      },
      "summary_fields": {
        "notification_template": {
          "id": 9,
          "name": "test",
          "description": ""
        }
      },
      "created": "2023-05-25T08:32:25.014485Z",
      "modified": "2023-05-25T08:32:25.014505Z",
      "notification_template": 9,
      "error": "Header part ({'short_description': 'Test Incident', 'assignment_group': 'A106'}) from {'extra_vars': {'short_description': 'Test Incident', 'assignment_group': 'A106'}} must be of type str or bytes, not <class 'dict'>",
      "status": "failed",
      "notifications_sent": 0,
      "notification_type": "webhook",
      "recipients": "https://servicenow-API.abc.com/api/dabas/incident_api/create/incident",
      "body": {
        "body": "Test Notification 9 https://awx.abc.com/"
      }
    }

Regards,
Vibin

AWX Project

unread,
May 26, 2023, 1:13:58 PM5/26/23
to AWX Project

The error you are getting (must be of type str or bytes not <class 'dict'>) is because that setting expects a dictionary of string: string. i.e.
{
    "header1": "value1",
    "header2": "value2"
}

But you have:
{
    "extra_vars": {...}
}  

So you are attempting to set the extra_vars header as a dict, not a string.
You may want to do something like:
{

    "short_description": "Test Incident",
    "assignment_group": "A106"
}

That should give you two headers set to two different values. If you really need to merge the values into a single header, you will need to look at the docs for what you are calling into and see how they allow for that.

-The AWX Team 

Vibin

unread,
May 29, 2023, 3:24:17 AM5/29/23
to AWX Project
Hi,

This is the way I call the API directly and it works -  curl -k -u svcaccount -X POST -H "Content-Type: application/json" https://servicenow-API.abc.com/api/dabas/incident_api/create/incident -d '{ "short_description": "Test Incident", "assignment_group": "A106" }'

But when I pass it as two headers set to two different values also, it doesn't take and throws error 417 which means the API didn't get the payload what it was looking for. 

So the question is how should we pass this payload in a way that the target API understands it correctly.

{
    "short_description": "Test Incident",
    "assignment_group": "A106"
}

Error:

{
  "id": 4006,
  "type": "notification",
  "url": "/api/v2/notifications/4006/",

  "related": {
    "notification_template": "/api/v2/notification_templates/9/"
  },
  "summary_fields": {
    "notification_template": {
      "id": 9,
      "name": "test",
      "description": ""
    }
  },
  "created": "2023-05-29T07:14:35.629791Z",
  "modified": "2023-05-29T07:14:35.629806Z",
  "notification_template": 9,
  "error": "Error sending webhook notification: 417",

  "status": "failed",
  "notifications_sent": 0,
  "notification_type": "webhook",
  "recipients": "https://servicenow-API.abc.com/api/dabas/incident_api/create/incident",
  "body": {
    "body": "Test Notification 9 https://awx.abc.com/"
  }
}

Regards,
Vibin

Vibin K Madampath

unread,
Jun 3, 2023, 12:06:18 PM6/3/23
to AWX Project
Hello Team,

Any further inputs is much appreciated.

Regards,
Vibin

Vibin

unread,
Jun 13, 2023, 2:58:29 AM6/13/23
to AWX Project

Hi Team,

Did you get a chance to check on this?

Just wondering whether this is a bug, because the feature is neither working as expected nor any clear documentation is available.

Would you like me to raise this as a bug.

Regards,
Vibin

AWX Project

unread,
Jun 14, 2023, 2:46:25 PM6/14/23
to AWX Project
From your curl command posted:

curl -k -u svcaccount -X POST -H "Content-Type: application/json" https://servicenow-API.abc.com/api/dabas/incident_api/create/incident -d '{ "short_description": "Test Incident", "assignment_group": "A106" }'

The -d is not a header, its a data sent via the HTTP POST body. Please look at the previously supplied documentation to see if there is a way to send post data with a webhook notification.

-The AWX Team.

Vibin

unread,
Jun 20, 2023, 9:40:32 AM6/20/23
to AWX Project
Hi, 

The mentioned documentation talks about the integration of github webhook with AWX and nothing about the webhook type notification template. Also, there is no field/option to send the data/payload to the webhook url in the GUI. 

AFAIK, with the current setup there is no possibility to send data/payload to the webhook type notification url and this should be a feature to get added in future releases. Also, more meaningful error messages will be helpful. 

Regards,
Vibin
Reply all
Reply to author
Forward
0 new messages