Skip to content

Commit

Permalink
Create /etc/hosts with sort to prevent unnecessary updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
VilleS1 committed Feb 4, 2020
1 parent 249b165 commit d1d2e67
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions templates/hosts.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit d1d2e67

Please sign in to comment.