Skip to content

Commit 8cd02d5

Browse files
author
Matt Pryor
committed
Populate /etc/hosts to allow hosts to refer to each other by name
1 parent 14c7504 commit 8cd02d5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

group_vars/cluster.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ secrets_openhpc_mungekey: "{{ hostvars[groups['control'][0]].ansible_local.openh
1111

1212
# Override this to cope with the case where the podman group just doesn't exist
1313
appliances_local_users_podman_enable: "{{ groups.get('podman', []) | length > 0 }}"
14+
15+
# Use the short hostname as the default internal address
16+
internal_address: "{{ ansible_hostname }}"

slurm-infra.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@
5454
loop: "{{ groups.get('cluster', []) }}"
5555
when: cluster_run_validation | default(false) | bool
5656

57+
# Ensure that the hosts in the cluster can all refer to each other by their inventory hostname
58+
- hosts: cluster
59+
become: yes
60+
tasks:
61+
- name: Populate /etc/hosts with cluster hosts
62+
lineinfile:
63+
path: /etc/hosts
64+
regexp: "{{ hostvars[host].ansible_hostname }}"
65+
line: "{{ hostvars[host].ansible_default_ipv4.address }} {{ hostvars[host].ansible_fqdn }} {{ hostvars[host].ansible_hostname }}"
66+
loop: "{{ ansible_play_hosts }}"
67+
loop_control:
68+
loop_var: host
69+
5770
# Ensure that the secrets are generated and persisted on the control host
5871
- name: Generate and persist secrets
5972
hosts: control

0 commit comments

Comments
 (0)