{% for host in groups['zookeeper'] -%}
{% if hostvars[host].ansible_facts.hostname == ansible_facts.hostname -%}
{{ loop.index }}
{%- endif %}
{%- endfor %}