Skip to content

Commit b71c1b3

Browse files
committed
use actual system hostname in /etc/hosts templating
1 parent c6596fe commit b71c1b3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ansible/bootstrap.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
when: "'secrets_openhpc_' in (hostvars[inventory_hostname] | join)"
1515

1616
- hosts: etc_hosts
17-
gather_facts: false
17+
gather_facts: yes
1818
tags: etc_hosts
1919
become: yes
2020
tasks:

ansible/roles/etc_hosts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# etc_hosts
22

3-
Hosts in the `etc_hosts` groups have `/etc/hosts` created. The generated file defines all hosts in this group using `ansible_host` as the IP address and `inventory_hostname` as the canonical hostname. This may need overriding for multi-homed hosts. See `environments/common/inventory/group_vars/all/cloud_init.yml` for configuration.
3+
Hosts in the `etc_hosts` groups have `/etc/hosts` created. The generated file defines all hosts in this group using `ansible_host` as the IP address and `inventory_nodename` as the canonical hostname. This may need overriding for multi-homed hosts. See `environments/common/inventory/group_vars/all/cloud_init.yml` for configuration.
44

55
# Variables:
66

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
22
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
33

4-
{% for hostname in groups['etc_hosts'] | sort -%}
5-
{{ hostvars[hostname]['ansible_host'] }} {{ hostname }}
4+
{% for inventory_hostname in groups['etc_hosts'] | sort -%}
5+
{{ hostvars[inventory_hostname]['ansible_host'] }} {{ hostvars[inventory_hostname]['ansible_nodename'] }}
66
{% endfor -%}

0 commit comments

Comments
 (0)