https://gist.github.com/anonymous/1ca1385f46a688ed2561
The output I see is:
"loseDoubleQuotes": [{'name2': 'value2nestedValue'}]
What I expect to see is:
"loseDoubleQuotes": [{"name2": "value2nestedValue"}]
Thanks for looking.
Rob
On Thursday, May 1, 2014 2:25:41 PM UTC-7, Michael DeHaan wrote:
>
> This is hard for me to follow where you have defined these variables, how
> about sharing everything in a gist?
>
>
>
>
> On Wed, Apr 30, 2014 at 3:02 PM, RobL <[email protected] <javascript:>>wrote:
>
>> Hi:
>>
>> I'm trying to use the template module to create a JSON file.
>>
>> I'm hitting an issue where some of my double-quotes are converting to
>> single quotes. Is there a way to ensure that Jinja2 won't do this
>> conversion? Notice how output.json has double-quotes for the first
>> variable but single-quotes for the second variable. I've tried various
>> ways of quoting, both in the template and in values.json.
>>
>> Sample hitting the issue:
>>
>> output.json:
>> {
>> "keepDoubleQuotes": [ {"name": "value"} ],
>> "loseDoubleQuotes": [{'name2': 'value2nestedValue'}]
>> }
>>
>> test/tasks/main.yml:
>> ---
>> - name: dbg
>> debug: var=keepDoubleQuotes
>>
>> - name: dbg2
>> debug: var=loseDoubleQuotes
>>
>> - name: template
>> template: src="test.j2"
>> dest="/var/tmp/output.json"
>>
>> test/templates/test.j2:
>> {
>> "keepDoubleQuotes": {{ keepDoubleQuotes}},
>> "loseDoubleQuotes": {{ loseDoubleQuotes}}
>> }
>>
>> test/values.json:
>> {
>> keepDoubleQuotes: '[
>> {"name": "value"}
>> ]',
>> "nestedVar": "nestedValue",
>> loseDoubleQuotes: '[
>> { "name2": "value2{{ nestedVar }}" }
>> ]',
>> }
>>
>> command line:
>> ansible-playbook -e "@test/values.json" -vvvv ./test.yml
>>
>> Output:
>> TASK: [test | dbg]
>> ************************************************************
>> ok: [...] => {
>> "item": "",
>> "keepDoubleQuotes": [
>> {
>> "name": "value"
>> }
>> ]
>> }
>>
>> TASK: [test | dbg2]
>> ***********************************************************
>> ok: [...] => {
>> "item": "",
>> "loseDoubleQuotes": [
>> {
>> "name2": "value2nestedValue"
>> }
>> ]
>> }
>>
>>
>>
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/1ee39758-80a7-48fe-a2ca-059b11a6c000%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/1ee39758-80a7-48fe-a2ca-059b11a6c000%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/3f39bd58-3073-4c70-b55c-790c3d0b63d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.