sidn-lxd-ansible-demo/roles/hostsfile/templates/hosts.j2

30 lines
798 B
Django/Jinja

# {{ ansible_managed }}
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 ip6-localhost ip6-loopback localhost6 localhost6.localdomain6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# Hosts within Ansible environment
{% set seen = [ ] %}
{% for group in ip %}
{% for network in ip[group] %}
{% if "address" in ip[group][network] %}
{% set hosts = [ ip[group][network] ] %}
{% else %}
{% set hosts = ip[group][network] %}
{% endif %}
{% for host in hosts %}
{% if host.address not in seen %}
{% do seen.append(host.address) %}
{{ host.address }} {{ host.hostnames | join(' ') }}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}