My solution was:
1. Convert array variable into string:
{"ansible_facts": {"junction_list": [{"AuthenticationHTTPheader":
"[iv_user, iv_groups]", ...
2. Get rid of quotes in a body:
body:
'{
...
"remote_http_header": {{
item.AuthenticationHTTPheader|default (d_remhed) }},
...
}'
понедельник, 10 июля 2017 г., 18:05:44 UTC+2 пользователь VenomMsk написал:
>
> Hi,
>
> I have a varible that contains an array:
>
> "AuthenticationHTTPheader": [
> "iv-user",
> "iv-groups"
> ],
>
>
> I need to pass this walue as a JSON-element in a body of a Request sent by
> URI module. So,
>
> body:
> '{
> ...
> "remote_http_header": "{{
> item.AuthenticationHTTPheader|default (d_remhed) }}",
> ...
> }'
>
> in the output I see that URI module sends the following to the server:
>
> "remote_http_header": "[u'iv-user', u'iv-groups']",
>
> here ->
> https://stackoverflow.com/questions/41521138/ansible-template-adds-u-to-array-in-template
>
> <- I read, that " | to_json" could solve the problem, but in my case using
> this breaks down the whole json of the body, it's no more a json, but a
> string with escaped quotes:
>
> ..., \"remote_http_header\": \"[\"iv-user\", \"iv-groups\"]\",...
>
> how can I send to the server this array? I need this to be sent to the
> server:
>
>
> "remote_http_header": [ "iv-user", "iv-groups"]
>
>
> Thanks to everybody!
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/58de8320-db17-418d-918f-45b31e495e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.