You are just giving your curl command the python data structure of
`eck_logs` and effectively you get a text representation of the data which
includes the `u` prefix to indicate Unicode.

You likely want to do the following instead:

{{ eck_logs|to_json }}

To output the data in JSON format.

On Sat, Oct 21, 2017 at 10:23 AM wildfan <tsheri...@gmail.com> wrote:

> I have wasted way too much time on this seemingly simple solution, and was
> looking for some help.
>
> We have a Tower job to deploy AWS cloudwatch and configure the logs to
> monitor that is kicked off via a callback.  I use the following curl-
>
> The callback is:
> curl -f -k -H 'Content-Type: application/json' -XPOST -d '{"host_config_key":
> "xxxxx", "extra_vars": "{\"logs\":{{ eck_logs }},\"env_stage\":\"dev\"}"}'
>  "https://tower.xxxx.net:443/api/v1/job_templates/xx/callback/";
>
> Which expands to
> "curl -f -k -H 'Content-Type: application/json' -XPOST -d
> '{\"host_config_key\": \"xxx\", \"extra_vars\":
> \"{\\\"logs\\\":\\\"[{u'file': u'/apps/app1/shared/logs/catalina.out',
> u'group_name': u'/on-premise/app1/container'}, {u'file':
> u'/apps/app1/shared/logs/app1-webapp.log', u'group_name':
> u'/on-premise/app1-webapp/applog'}]\\\",\\\"env_stage\\\":\\\"dev\\\"}\"}'
> \"https://tower.xxx.net:443/api/v1/job_templates/xx/callback/\"";..
>
> The eck_logs variable looks like
> "eck_logs": [
>             {
>                 "file": "/apps/app1/shared/logs/catalina.out",
>                 "group_name": "/on-premise/app1/container"
>             },
>             {
>                 "file": "/apps/app1/shared/logs/app1-webapp.log",
>                 "group_name": "/on-premise/app1/applog"
>             }
>         ]
>
> The issue i am running into is, i believe all about quoting..  as it is
> currently, it will pass the variable to the Tower job, however it tacks on
> the "u" for unicode to the variable resulting in:
>
> logs:
>   - ugroup_name: u/on-premise/app1-webapp/container
>     ufile: u/apps/app1/shared/logs/catalina.out
>   - ugroup_name: u/on-premise/app1/applog
>     ufile: u/apps/app1/shared/logs/app1-webapp.log
>
>
>
> when i quote the eck_logs variable in the curl command, i then instead get-
>
> command:
> curl -f -k -H 'Content-Type: application/json' -XPOST -d
> '{"host_config_key": "xxx", "extra_vars": "{\"logs\":\"{{ eck_logs
> }}\",\"env_stage\":\"dev\"}"}'  "
> https://tower.xxx.net:443/api/v1/job_templates/xxx/callback/";
>
> result
> "curl -f -k -H 'Content-Type: application/json' -XPOST -d
> '{\"host_config_key\": \"xxx\", \"extra_vars\":
> \"{\\\"logs\\\":\\\"[{u'file': u'/apps/app1/shared/logs/catalina.out',
> u'group_name': u'/on-premise/app1/container'}, {u'file':
> u'/apps/app1/shared/logs/app1-webapp.log', u'group_name':
> u'/on-premise/app1-webapp/applog'}]\\\",\\\"env_stage\\\":\\\"dev\\\"}\"}'
> \"https://tower.xxx.net:443/api/v1/job_templates/xxx/callback/\"";
>
> Variable on Tower:
> logs: >-
>   [{ufile: u/apps/app1/shared/logs/catalina.out, ugroup_name:
>   u/on-premise/app1/container}, {ufile:
>   u/apps/app1/shared/logs/app1-webapp.log, ugroup_name:
>   u/on-premise/app1/applog}]
>
>
>
> I have tried seemingly every filter, quoting, escaping I can and i can't
> get the desired variable value when passing tower..
>
> I am looking for the results in my first example for the logs variable
> (list), but without the leading "u" getting added to the values..
>
> I realize this might be a mixture of a jinja/ansible question , but does
> anyone have any ideas on what i can try to fix this?
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0ab058e1-63f5-4079-8037-941ba407971b%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0ab058e1-63f5-4079-8037-941ba407971b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_g-AJXeZH_4H4exv34DOWbUdoRJ6Z6m7-2_2FX2q6jbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to