Issue Type: Bug Report
Ansible Version: 1.9.4
Environment: OSX 10.11.1
Summary: Using lookup
to render a template that gets passed into the uri
module's body
parameter does not work. It throws an TypeError: unhashable type
error. I opened a StackOverflow question about this, and thought it made sense to post it here as well.
Steps To Reproduce:
Run this task:
- name: Post
uri:
url: https://hooks.slack.com/endpoint
method: POST
return_content: no
HEADER_Content-Type: "application/json"
body: "{{ lookup('template', '../templates/my.json.j2', convert_data=False) }}"
with this in my.json.j2
:
{
"channel": "chatops",
"username": "Deploy",
"text": "TEST Deploy!",
"icon_emoji": ":ghost:"
}
Folding the JSON into a single line within the template has the same effect. Piping the lookup
response through to_json
also does not work. Taking the folded JSON and using it _directly_ in the play does work, however.
Expected result: proper JSON sent to endpoint
Actual result: TypeError: unhashable type
error; also, in certain circumstances, a not valid JSON
error is returned by the endpoint, which indicates that the data is not being sent properly.
Hi!
Thanks very much for your interest in Ansible. It sincerely means a lot to us.
This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.
If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.
Thank you once again and we look forward to seeing you on the list or IRC. Thanks!
This was fixed in 2.0: just add _body_format: json_ to uri module (and remove _convert_data=False_)
Also, you don't have to set the Content-Type header yourself when setting body_format to json.
Hi, any support regarding this issue:
http://stackoverflow.com/questions/43117635/ansible-variable-not-rendered-inside-json-object
Most helpful comment
This was fixed in 2.0: just add _body_format: json_ to uri module (and remove _convert_data=False_)
Also, you don't have to set the Content-Type header yourself when setting body_format to json.