From d1d2e674976092c96c8d8c2ed83e05714c7e33c3 Mon Sep 17 00:00:00 2001 From: VilleS1 Date: Tue, 4 Feb 2020 19:58:04 +0200 Subject: [PATCH] Create /etc/hosts with sort to prevent unnecessary updates. --- templates/hosts.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/hosts.j2 b/templates/hosts.j2 index 149440a..a03c4d5 100644 --- a/templates/hosts.j2 +++ b/templates/hosts.j2 @@ -3,12 +3,17 @@ 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 -# Hosts from ansible hosts file -{% for host in groups['all'] %} +# Hosts from ansible hosts file, internal ip +{% for host in groups['all'] | sort %} {% if hostvars[host].int_ip_addr is defined %} {{ hostvars[host].int_ip_addr }} {{ hostvars[host].inventory_hostname_short }}.{{ intDomain }}.{{ siteDomain }} {{ hostvars[host].inventory_hostname_short }} {% endif %} +{% endfor %} + +# Hosts from ansible hosts file, infiniband ip +{% for host in groups['all'] | sort %} {% if hostvars[host].ib_ip_addr is defined %} {{ hostvars[host].ib_ip_addr }} {{ hostvars[host].inventory_hostname_short }}-ib.{{ intDomain }}.{{ siteDomain }} {{ hostvars[host].inventory_hostname_short }}-ib {% endif %} {% endfor %} +