Notification is not sent when custom data in the notification template contains a string that contains double or single quotes. I am using a webhook, that posts some data. I am also using job.artifacts to pass some data to the notification template. I have listed the two problamatic cases below.
Has anyone encountered this or is fmailiar with what is the cause for this behaviour.
Any help is highly appreciated ![]()
AWX version
23.5.1
Ansible version
2.11.12
Operating system
CentOS
Steps to reproduce
A playbook that contains the following:
- hosts: all
gather_facts: true
tasks:
- name: "[playbook_simple_test] Test Task."
ansible.builtin.set_stats:
aggregate: false
per_host: false
data:
"{{ data_obj }}"
register: some_test
The notification template contains the following:
- Created:
{{ job_metadata }}
- Success message body:
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
- Error message body:
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
There are the following three cases in a job template:
- w/o double quotes ("):
Extra-vars:
{
"data_obj": {
"some_str": "This contains no double quotes."
}
}
- contains double quotes ("):
Extra-vars:
{
"data_obj": {
"some_str": "This contains double quotes \" in the middle of text."
}
}
- contains a stringified json
{
"data_obj": {
"some_str": "{\"key1\": \"value1\", \"key2\": \"value2\"}"
}
}
Expected results
metadata
{âjob.idâ: âxxxxxâ, âjob.statusâ: âsuccessfulâ, âjob.artifactsâ: {âsome_strâ: âstring contentâ}}
Actual results
-
w/o double quotes in string:
metadata
{âjob.idâ: âxxxxxâ, âjob.statusâ: âsuccessfulâ, âjob.artifactsâ: {âsome_strâ: âThis contains double quotes " in the middle of text.â}} -
contains double quotes ("):
metadata
No Notification -
contains stringified json:
metadata
No Notification