diff --git a/defaults/main.yml b/defaults/main.yml index 48f388e..39cf852 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,3 +5,8 @@ network_defaultif: eth0 network_disable_ipv6: false network_dns_server: 8.8.8.8 network_interfaces: {} +network_hosts_entries: [] +# network_hosts_entries: +# - hostname: myhost +# fqdn: myhost.rknet.org +# address: 1.2.3.4 diff --git a/templates/etc/hosts.j2 b/templates/etc/hosts.j2 index 230f76f..990cbbb 100644 --- a/templates/etc/hosts.j2 +++ b/templates/etc/hosts.j2 @@ -1,4 +1,4 @@ -#jinja2: trim_blocks: True, lstrip_blocks: True +#jinja2: lstrip_blocks: True # {{ ansible_managed }} 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 {% if network_disable_ipv6 == false %} @@ -7,3 +7,6 @@ {% if network_hostname is defined and network_fqdn is defined and network_interfaces[network_defaultif].ipaddr is defined %} {{ network_interfaces[network_defaultif].ipaddr }} {{ network_fqdn }} {{ network_hostname }} {% endif %} +{% for item in network_hosts_entries %} +{{ item.address }} {{ item.fqdn }} {{ item.hostname }} +{% endfor %}