Can any one help me with the below, im trying to reference variables from my inventory file in a jinja2 hostvars loop. Ive copied the host file and jinja template below.
Template File
In my Jinja 2 template i have the following loop
{% for host in groups[‘redishosts’:‘haproxyhosts’] %}
sentinel known-sentinel mymaster {{ hostvars[host][‘ansible_eth0’][‘ipv4’][‘address’] }} 26379 {{ hostvars[host][‘sentinel_id’].value }}
{% endfor %}
The idea being that i want to pull the variables ie the systems ip and the sentinel_id varaible from the host facts and inventory file variable, listed below
Thanks both worked but I have a new error. Ansible undefined variable. Then it prints out the sentinel id. So it does see the content of the sentinel_id host file variable .