Hi,
Im having an issue with the following Jinja2 template and I just cant figure out how to get it to display the ip4 addresses of the hosts from the hostvars for the hosts in the inventory file below
{% for host_system in groups['hosts'] %}
{% if "ansible_eth0" in hostvars[host_system] -%}
sentinel known-sentinel mymaster {{ hostvars[host_system]['ansible_eth0']['ipv4']['address'] }} 26379 {{ hostvars[host_system]['sentinel_id'] }}
{%- endif -%}
{% endfor %}
Inventory
[hosts:children]
haproxyhosts
redishosts
[haproxyhosts]
Hahost1
Hahost2
[redishosts]
Rhost1
Rhost2
Error
fatal: [10.193.45.158]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"daemon_reload": false,
"enabled": true,
"masked": null,
"name": "redis-sentinel",
"state": "restarted",
"user": false
}
},
"msg": "Unable to restart service redis-sentinel: Job for redis-sentinel.service failed because the control process exited with error code. See \"systemctl status redis-sentinel.service\" and \"journalctl -xe\" for details.\n"
}
fatal: [10.193.45.157]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"daemon_reload": false,
"enabled": true,
"masked": null,
"name": "redis-sentinel",
"state": "restarted",
"user": false
}
},
"msg": "Unable to restart service redis-sentinel: Job for redis-sentinel.service failed because the control process exited with error code. See \"systemctl status redis-sentinel.service\" and \"journalctl -xe\" for details.\n"
}