So I’m able to create the dictionary, and I can convert it to JSON in a debug statement, but when I try to convert it to JSON in the URI module it throws an unhandled exception. What’s going on here?
ansible --version ?
Also not that this means it shouldn’t raise an error but, this is easier:
debug: var=stash_json
ansible 1.4.4
My confusion is that:
msg: ‘{{ stash_json | to_json }}’
works just fine, so it’s not the to_json filter in and of itself that’s causing the bug. It’s using it in the uri module (or maybe just the body parameter).
Actually, no, the above traceback does not have anything to do with the URI module.
Please make sure there’s a github filed on it though as I’d like to understand the cause of it.
Thanks!
This is a similar stack trace triggered by the same Python syntax
error noted in:
https://github.com/ansible/ansible/issues/5566
Unfortunately the syntax error masks the real issue.
Does it work if you '>' escape the jason string as follows?
- set_fact:
stash_json: >
{ text: "some thing" }
K
Kahlil (Kal) Hodgson GPG: C9A02289
Head of Technology (m) +61 (0) 4 2573 0382
DealMax Pty Ltd (w) +61 (0) 3 9008 5281
Suite 1415
401 Docklands Drive
Docklands VIC 3008 Australia
"All parts should go together without forcing. You must remember that
the parts you are reassembling were disassembled by you. Therefore,
if you can't get them together again, there must be a reason. By all
means, do not use a hammer." -- IBM maintenance manual, 1925
To avoid confusion, this is not escaping. This is a “folded block”, which is a way of inputting data over multiple lines.
http://yaml.org/spec/1.2/spec.html#style/block/folded
–Michael