Update cluster config var to include public+private addresses

This commit is contained in:
2021-11-13 19:24:59 -05:00
parent 20450332d4
commit f178a7bf78
5 changed files with 33 additions and 27 deletions

View File

@@ -9,12 +9,10 @@
vars:
_hostsfile_lines: []
ansible.builtin.set_fact:
_hostsfile_lines: "{{ _hostsfile_lines + [item.address + ' ' + item.hostname] }}"
loop: "{{ skylab_direct_peers }}"
loop_control:
label: "{{ item.hostname }}"
_hostsfile_lines: "{{ _hostsfile_lines + [hostvars[item].skylab_cluster.address.internal | ansible.netcommon.ipaddr('address') + ' ' + item + '.local ' + hostvars[item].skylab_legacy_names | default([]) | join(' ')] }}"
loop: "{{ groups.cluster }}"
- name: Configure directly connected peers
- name: Configure local hostsfile
become: true
ansible.builtin.lineinfile:
path: /etc/hosts
@@ -24,7 +22,7 @@
loop_control:
label: "{{ item.partition(' ')[0] }}"
- name: Remove unmanaged peer aliases
- name: Remove unmanaged hostsfile entries
become: true
when: "'localhost' not in item and item not in _hostsfile_lines"
ansible.builtin.lineinfile:

View File

@@ -14,8 +14,8 @@
ansible.builtin.include_tasks: firewalld.yaml
- name: Configure hostsfile
when: skylab_direct_peers is defined
ansible.builtin.include_tasks: hosts.yaml
when: "inventory_hostname in groups.cluster"
ansible.builtin.import_tasks: hosts.yaml
- name: Enable tmpfs mount
become: true