Re: [ansible-project] Re: Prevent ansible from re-ordering JSON?

2018-11-07 Thread Brian Coca
To 'keep it a string'  content: "{{ my_var|string }}" , from_json
actually forces conversion (which would be happening anyways)



-- 
--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7e4V5SuH6KGLvJEijTRHZDJkSjhOFnvOAWE-NvWDYGZ7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Prevent ansible from re-ordering JSON?

2018-11-06 Thread Eddie Mashayev
Hey Kai,

The thing is that is not a *dictionary* but *string*, pay attention to the
"|" after my_var:

my_var: |
  {
"b": 1
"a": 2
  }

So the question is still the same, why string is unordered in Ansible?

Thanks,
Eddie Mashayev
Cell : 054-4692519


On Tue, Nov 6, 2018 at 8:17 PM Eddie Mashayev  wrote:

> Thanks.
>
> On Tuesday, November 6, 2018 at 3:20:15 PM UTC+2, Eddie Mashayev wrote:
>>
>> Hey,
>>
>> I've this weird situation when I'm passing json(as a string) it still
>> reordering it's order and not consistent.
>>
>> Example:
>>
>> my_var: |
>>   {
>> "b": 1
>> "a": 2
>>   }
>>
>>
>> when running ansible with
>>
>> - name: "Set up json file"
>>   copy:
>> dest: "/tmp/file.json"
>> content: "{{ my_var }}"
>>
>>
>> every ansible run the file is being changed(because json order is being
>> changed), in order to fix it I'm using:
>> content: "{{ my_var | from_json | to_nice_json }}"
>>
>> This command keeps the order the same each run, because to_nice_json
>> 
>> sorts the output (`sort_keys=True`).
>>
>> My question is why *my_var* is being changed all the time even it's a
>> string and *not* json
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/2if2Cy_pHfM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0e6051f2-8f2f-4763-8d84-4d3530024e71%40googlegroups.com
> 
> .
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CABO9khou0SWZVEsxDFMnAYA8eOeBBWKKLw2_HoUFjN%2BUv2Xgrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Prevent ansible from re-ordering JSON?

2018-11-06 Thread Eddie Mashayev
Thanks.

On Tuesday, November 6, 2018 at 3:20:15 PM UTC+2, Eddie Mashayev wrote:
>
> Hey,
>
> I've this weird situation when I'm passing json(as a string) it still 
> reordering it's order and not consistent.
>
> Example:
>
> my_var: |
>   {
> "b": 1
> "a": 2
>   }
>
>
> when running ansible with
>
> - name: "Set up json file"
>   copy:
> dest: "/tmp/file.json"
> content: "{{ my_var }}"
>
>
> every ansible run the file is being changed(because json order is being 
> changed), in order to fix it I'm using:
> content: "{{ my_var | from_json | to_nice_json }}"
>
> This command keeps the order the same each run, because to_nice_json 
> 
>  
> sorts the output (`sort_keys=True`).
>
> My question is why *my_var* is being changed all the time even it's a 
> string and *not* json
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0e6051f2-8f2f-4763-8d84-4d3530024e71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.