Closed jordiclariana closed 6 years ago
Hey, thank you for contribution :+1: everything looks good to me expect new variable own
part, it lacks intention. How about zookeeper_hosts_hostname
?
Have you thought about multiple array declarations?
zookeeper_hosts:
- host: "{{zookeeper_own_hostname}}" # the machine running
id: 1
- host: "{{zookeeper_own_hostname}}" # the machine running
id: 2
For example I am setting hosts with this block:
zookeeper_hosts: "
{%- set ips = [] %}
{%- for host in groups['zookeepers'] %}
{{- ips.append(dict(id=loop.index, host=host, ip=hostvars[host]['ansible_' + lo_host_ipv4_interface].ipv4.address)) }}
{%- endfor %}
{{- ips -}}"
No problem on the variable name change, it honestly makes sense.
About the case you mention, I think it will work with the default zookeeper_hosts_hostname: inventory_hostname
, because inventory_hostname
is the one returned by groups['zookeepers']
.
I tested locally and it is like this.
Neat! thank you for contribution :+1:
There are sometimes when
inventory_hostname
is not the real hostname of your machine, and you want to specify which fact from ansible represents better your hostname.For this I added
zookeeper_own_hostname
which by default equals toinventory_hostname
but let you for instance overwrite it byansible_nodename
or whatever other variable or value you need.This change is backwards compatible.