Hi Phil

Don't know if there is an official short way to do this, but there is a
'to_json' filter which seems to work on simple booleans, which could be
slightly preferable to 'lower'?

Tom

On 11 February 2015 at 00:24, Philip Lombardi <[email protected]> wrote:

> I have some variables defined in a role such as:
>
> ---
> # file: roles/consul/defaults/main.yml
> consul_server: yes
>
> And then I have a JSON template file with many settings for the software I
> am provisioning, but just for example:
>
> {
>   "server": {{ consul_server | bool }}
> }
>
>
> When Ansible/Jinja2 process the template I end up with an invalid JSON
> object because 'True' is not a valid JSON keyword:
>
> {
>   "server": True
> }
>
> I ended up doing this:
>
> {
>   "server": {{ consul_server | bool | lower }}
> }
>
> Which works... but it gets sloppy when there are a ton of variables in a
> file.
>
> So my question, what is the proper way to interpolate boolean values in a
> JSON file?
>
> Thank you for reading. Looking forward to the response(s).
>
> Regards,
> Phil
>
> --
> 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/b7b97826-dab2-40c9-8c37-75af8fef6a83%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b7b97826-dab2-40c9-8c37-75af8fef6a83%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/CAAnNz0PEqMc%3D4CuGA1rCMeWAZkPqq7-6qxzM297jbye_En7jFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to