This is not a simple problem, aside from an issue with Ansible internals, modules are inconsistent in what they expect when declaring these fields, some expect an actual JSON string, others expect a data structure to be converted (the better ones detect what they got and adjust).
The lookup itself does no transformations, the issue is with Jinja2 templating, it returns a string by default, so Ansible tries to detect 'type', this conflicts with JSON as any string starting with "[" or "{" is considered a list or dictionary respectively. This is done in an effort of preserving existing types in declared variables and we cannot effectively just 'turn off' without creating many other issues. To avoid this 'typing' there are a few of things that can be done: - in all versions of Ansible, put in a preceding space " {{lookup... ", this will skip type detection. - in the latest versions a `|to_json` and certain other filters at the end will also bypass the automatic type casting. We are also adding a new feature for modules in 2.2 a type='json' which will accept both JSON strings and/or python data structures which will automatically be transformed to JSON. This will effectively be the same as 'the better modules' I mention above and will be 'transparent' to users, eventually eliminating the problem and confusion. ---------- Brian Coca -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.