So I’m in a rut.. I have this line in my template. Basically I have set a
variable in my inventory file and im trying to access it in my Jinja2
template but as you can guess it’s not working.
I need to have the template add the slaveof line on hosts that don’t have
the slave string set.
[root@p-mgmt01 redis]# cat hostscert
[haproxyhosts]
10.193.45.147 keepalived_role=master
10.193.45.148 keepalived_role=slave
[redishosts]
10.193.45.145 redis_role=master
10.193.45.146 redis_role=slave
[redishosts:vars]
sentinelMaster=10.193.45.145
authpass='cert-0c924c2361df3473823ab64ab36c33t38'
[haproxyhosts:vars]
virtual_redis_vip=3.0.0.55
sentinelMaster=10.193.45.145
authpass='cert-0c9e4cdc61gf3472803ab64eb56363c12'
keepalived_router_id='33'
*Template Code:*
{% for host in redishosts %}
{% if redis_role.lower() == "slave" %}
slaveof {{
hostvars[groups['redishosts'][0]]['ansible_eth0']['ipv4']['address'] }} 6379
{% endif %}
{% endfor %}
--
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/a244631f-7cc0-4570-87d4-61a6e551743b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.