Update cluster config var to include public+private addresses
This commit is contained in:
parent
20450332d4
commit
f178a7bf78
@ -34,21 +34,19 @@ en1:
|
|||||||
- server
|
- server
|
||||||
- datastore
|
- datastore
|
||||||
- swarm
|
- swarm
|
||||||
skylab_direct_peers:
|
|
||||||
- hostname: pegasus.local jupiter.svr.local
|
|
||||||
address: 192.168.42.10
|
|
||||||
- hostname: saturn.local remus.svr.local
|
|
||||||
address: 192.168.42.20
|
|
||||||
- hostname: orion.local
|
|
||||||
address: 192.168.42.30
|
|
||||||
|
|
||||||
hosts:
|
hosts:
|
||||||
pegasus: # jupiter
|
pegasus: # jupiter
|
||||||
ansible_host: 10.42.101.100
|
ansible_host: 10.42.101.100
|
||||||
skylab_hostname: pegasus.skylab.enp.one
|
skylab_hostname: pegasus.skylab.enp.one
|
||||||
|
skylab_legacy_names:
|
||||||
|
- jupiter.net.enp.one
|
||||||
|
- jupiter.svr.local
|
||||||
skylab_description: Arbiter Node
|
skylab_description: Arbiter Node
|
||||||
skylab_cluster:
|
skylab_cluster:
|
||||||
address: 10.42.101.10/24
|
address:
|
||||||
|
access: 10.42.101.10/24
|
||||||
|
internal: 192.168.42.10/24
|
||||||
interface:
|
interface:
|
||||||
access: bond0
|
access: bond0
|
||||||
internal: bond0.99
|
internal: bond0.99
|
||||||
@ -77,9 +75,14 @@ en1:
|
|||||||
saturn: # remus
|
saturn: # remus
|
||||||
ansible_host: 10.42.101.110
|
ansible_host: 10.42.101.110
|
||||||
skylab_hostname: saturn.skylab.enp.one
|
skylab_hostname: saturn.skylab.enp.one
|
||||||
|
skylab_legacy_names:
|
||||||
|
- remus.net.enp.one
|
||||||
|
- remus.svr.local
|
||||||
skylab_description: Operational Node
|
skylab_description: Operational Node
|
||||||
skylab_cluster:
|
skylab_cluster:
|
||||||
address: 10.42.101.11/24
|
address:
|
||||||
|
access: 10.42.101.11/24
|
||||||
|
internal: 192.168.42.20/24
|
||||||
interface:
|
interface:
|
||||||
access: bond0
|
access: bond0
|
||||||
internal: bond0.99
|
internal: bond0.99
|
||||||
@ -108,9 +111,14 @@ en1:
|
|||||||
orion: # romulus
|
orion: # romulus
|
||||||
ansible_host: 10.42.101.120
|
ansible_host: 10.42.101.120
|
||||||
skylab_hostname: orion.skylab.enp.one
|
skylab_hostname: orion.skylab.enp.one
|
||||||
|
skylab_legacy_names:
|
||||||
|
- romulus.net.enp.one
|
||||||
|
- romulus.svr.local
|
||||||
skylab_description: Operational Node
|
skylab_description: Operational Node
|
||||||
skylab_cluster:
|
skylab_cluster:
|
||||||
address: 10.42.101.12/24
|
address:
|
||||||
|
access: 10.42.101.12/24
|
||||||
|
internal: 192.168.42.30/24
|
||||||
interface:
|
interface:
|
||||||
access: bond0
|
access: bond0
|
||||||
internal: bond0.99
|
internal: bond0.99
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
when: inventory_hostname != _target_node
|
when: inventory_hostname != _target_node
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- skylab_cluster.address | ansible.netcommon.ipaddr('address') in _node_addresses
|
- skylab_cluster.address.access | ansible.netcommon.ipaddr('address') in _node_addresses
|
||||||
- _docker_node_availability | lower == 'active'
|
- _docker_node_availability | lower == 'active'
|
||||||
fail_msg: >-
|
fail_msg: >-
|
||||||
ERROR: Node '{{ inventory_hostname }}' is already marked as unavailable. All cluster
|
ERROR: Node '{{ inventory_hostname }}' is already marked as unavailable. All cluster
|
||||||
@ -115,15 +115,15 @@
|
|||||||
|
|
||||||
- name: Delete address from node
|
- name: Delete address from node
|
||||||
become: true
|
become: true
|
||||||
when: skylab_cluster.address | ansible.netcommon.ipaddr('address') in _node_addresses
|
when: skylab_cluster.address.access | ansible.netcommon.ipaddr('address') in _node_addresses
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: ip address delete {{ skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
cmd: ip address delete {{ skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
- name: Assign address to alt node
|
- name: Assign address to alt node
|
||||||
delegate_to: "{{ _target_alt }}"
|
delegate_to: "{{ _target_alt }}"
|
||||||
become: true
|
become: true
|
||||||
when: skylab_cluster.address | ansible.netcommon.ipaddr('address') not in hostvars[_target_alt]._node_addresses
|
when: skylab_cluster.address.access | ansible.netcommon.ipaddr('address') not in hostvars[_target_alt]._node_addresses
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: ip address add {{ skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') }} dev {{ hostvars[_target_alt].skylab_cluster.interface.access }}
|
cmd: ip address add {{ skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') }} dev {{ hostvars[_target_alt].skylab_cluster.interface.access }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
@ -37,12 +37,12 @@
|
|||||||
vars:
|
vars:
|
||||||
_cluster_node_ips: []
|
_cluster_node_ips: []
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
_cluster_node_ips: "{{ _cluster_node_ips + [hostvars[item].skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix')] }}"
|
_cluster_node_ips: "{{ _cluster_node_ips + [hostvars[item].skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix')] }}"
|
||||||
loop: "{{ groups.cluster }}"
|
loop: "{{ groups.cluster }}"
|
||||||
|
|
||||||
- name: Remove alternative node IPs
|
- name: Remove alternative node IPs
|
||||||
become: true
|
become: true
|
||||||
when: item in _cluster_node_ips and item != (skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix'))
|
when: item in _cluster_node_ips and item != (skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix'))
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: ip address delete {{ item | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
cmd: ip address delete {{ item | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
- name: Add node IP
|
- name: Add node IP
|
||||||
become: true
|
become: true
|
||||||
when: skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') not in _node_addresses
|
when: skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') not in _node_addresses
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: ip address add {{ skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
cmd: ip address add {{ skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
@ -9,12 +9,10 @@
|
|||||||
vars:
|
vars:
|
||||||
_hostsfile_lines: []
|
_hostsfile_lines: []
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
_hostsfile_lines: "{{ _hostsfile_lines + [item.address + ' ' + 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: "{{ skylab_direct_peers }}"
|
loop: "{{ groups.cluster }}"
|
||||||
loop_control:
|
|
||||||
label: "{{ item.hostname }}"
|
|
||||||
|
|
||||||
- name: Configure directly connected peers
|
- name: Configure local hostsfile
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/hosts
|
path: /etc/hosts
|
||||||
@ -24,7 +22,7 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.partition(' ')[0] }}"
|
label: "{{ item.partition(' ')[0] }}"
|
||||||
|
|
||||||
- name: Remove unmanaged peer aliases
|
- name: Remove unmanaged hostsfile entries
|
||||||
become: true
|
become: true
|
||||||
when: "'localhost' not in item and item not in _hostsfile_lines"
|
when: "'localhost' not in item and item not in _hostsfile_lines"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
ansible.builtin.include_tasks: firewalld.yaml
|
ansible.builtin.include_tasks: firewalld.yaml
|
||||||
|
|
||||||
- name: Configure hostsfile
|
- name: Configure hostsfile
|
||||||
when: skylab_direct_peers is defined
|
when: "inventory_hostname in groups.cluster"
|
||||||
ansible.builtin.include_tasks: hosts.yaml
|
ansible.builtin.import_tasks: hosts.yaml
|
||||||
|
|
||||||
- name: Enable tmpfs mount
|
- name: Enable tmpfs mount
|
||||||
become: true
|
become: true
|
||||||
|
Reference in New Issue
Block a user