I am wondering if this is possible I have a group_vars file with some
variables in it, and I need to set, the list is generated from the
inventory and a mapping to the ec2 private ip address.
For example in my group_vars file:
cassandra: {keyspace: default, log_time: false, hosts: [ "{% for host in
groups['tag_role_cassandra_true']
%}{{hostvars[host].ec2_private_ip_address}}{% if not loop.last %},{% endif
%}{% endfor %}" ]}
This ends up being the following if I dump it using the "debug" directive:
"msg": "cassandra {'keyspace': 'default', 'log_time': False, 'hosts':
[u'172.31.2.85,172.31.2.84,172.31.2.86,172.31.2.83']}"
As you can see that is a list of one string. I want a list of all hosts, in
this case four hosts, i.e it should be:
'hosts': ['172.31.2.85', '172.31.2.84' ,'172.31.2.86', '172.31.2.83']
Does anyone know anyway to loop over all the hosts do the conversion to
private ip and append to the "list".
My fallback is to generate it as a string, then use that lower down , but
would be nice to have the list, as I can output it in various templates
differently.
Thanks
--
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/572e3dba-2fc4-4f6b-8a7a-de506a1f02c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.