{%- set stack_hosts = salt['mine.get']('stack_id:' ~ grains.stack_id, 'grains.items', 'grain') -%}
{%- if grains['os_family'] == 'Debian' -%}
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
{%- elif grains['os_family'] == 'RedHat' -%}
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
{% endif %}

{# On ubuntu, the network interface isn't called  #}
{% for items in stack_hosts.values() %}
{%- for ip_addr in items.ipv4 %}
{%- if ip_addr != '127.0.0.1' %}
{{ ip_addr }} {{ items.fqdn }} {{ items.id }}
{%- endif %}
{%- endfor %}
{%- endfor %}
