Double quotes in a host variable

279 views
Skip to first unread message

Harsh Jha

unread,
Jun 21, 2014, 8:54:44 PM6/21/14
to ansible...@googlegroups.com
My host inventory has a host specific variable and it looks as follows -

[local]
localhost

[server_nodes]
abcd.compute-1.amazonaws.com

[client_nodes]
xyz.compute-1.amazonaws.com subs="[\"elasticsearch_nodes\"]"
ghi.compute-1.amazonaws.com subs="\[\"elasticsearch_nodes\"\]"
jkl.compute-1.amazonaws.com subs='["nginx_nodes"]'


I'm talking about the "subs" variable here. I have tried using it in three different ways as shown above but none of them solves my purpose. Actually I want to keep double quotes. So if I put the following in a template file -

var1 = {{ subs }}

It should get converted to -

var1 = ["nginx_nodes"]

instead it gets converted to -

var1 = ['nginx_nodes']

I want to keep double quotes and avoid getting them converted to single quotes. Please provide some suggestions. Thanks.

Michael DeHaan

unread,
Jun 22, 2014, 12:06:47 PM6/22/14
to ansible...@googlegroups.com
It's much easier to put variables in host_vars/ or group_vars/ directories instead, which is something I'd consider doing.

If you want to define structured variables, like you seem to be doing above, you'll want this.

otherwise you're defining strings, which I don't think you want.




--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5f053918-8a78-49e0-951c-8f329f13fec8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages