Hi Guys,
It might be a stupid question, but how can i use facts as variable value in group vars?
I want to install Elastic search and want to have network.host to be filled automatically with the eth0.ip4 address.
role/template
{% if elasticsearch_network_host %}
network.host: {{ elasticsearch_network_host }}
{% else %}
role/defaults
elasticsearch_network_host: ‘{{ ansible_eth0[“ipv4”][0][“address”] }}’
group_vars:
elasticsearch_network_host: ‘{{ ansible_eth0[“ipv4”][0][“address”] }}’
Is there a way to achieve this?
It might be a stupid question, but how can i use facts as variable value in
group vars?
Using facts in group vars is very strange. Which of the hosts in the group would you like to be assign to the group vars.
I want to install Elastic search and want to have network.host to be filled
automatically with the eth0.ip4 address.
role/template
{% if elasticsearch_network_host %}
network.host: {{ elasticsearch_network_host }}
{% else %}
So, for each host you would like to add that host ip on eth0 in the Elasticsearch configuration file on that host?
You would achieve that by using this in your role/template
network.host: {{ ansible_eth0["ipv4"]["address"] }}