role_etc_hosts/templates/hosts.j2

29 lines
798 B
Plaintext
Raw Permalink Normal View History

2022-10-21 13:01:23 +00:00
# {{ ansible_managed }}
{%- if inventory_hostname != inventory_hostname_short %}
{%- set host = inventory_hostname ~ ' ' ~ inventory_hostname_short %}
{%- else %}
{% set host = inventory_hostname_short %}
{%- endif %}
{%- if etc_hosts_local | length > 0 %}
{% set line = host ~ ' ' ~ (etc_hosts_local | join(' ')) %}
{%- else %}
{% set line = host %}
{%- endif +%}
127.0.0.1 {{ line }} localhost
# The following lines are desirable for IPv6 capable hosts
::1 {{ line }} localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
{% if etc_hosts_specifics | length > 0 %}
# The following lines are specified by instance configuration
{{ etc_hosts_specifics | join('\n') }}
{% endif %}