2021-11-11 05:34:05 +00:00
|
|
|
---
|
|
|
|
- name: Online nodes
|
|
|
|
hosts: cluster
|
|
|
|
vars_prompt:
|
|
|
|
- name: skylab_datastore_encryption_password
|
|
|
|
prompt: Enter datastore block decryption password
|
|
|
|
private: true
|
|
|
|
roles:
|
|
|
|
- role: datastore
|
|
|
|
when: "'datastore' in skylab_roles | default([])"
|
|
|
|
tasks:
|
|
|
|
- name: Fetch node swarm ID
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: !unsafe docker info --format '{{ .Swarm.NodeID}}'
|
|
|
|
changed_when: false
|
|
|
|
register: _docker_node_id_raw
|
|
|
|
|
|
|
|
- name: Update node availability
|
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: "{{ skylab_state_dir }}/ansible-runtime/bin/python"
|
|
|
|
community.docker.docker_node:
|
|
|
|
availability: active
|
|
|
|
hostname: "{{ _docker_node_id_raw.stdout.strip() }}"
|
|
|
|
|
|
|
|
- name: Determine node addresses
|
|
|
|
vars:
|
|
|
|
_node_addresses:
|
|
|
|
- "{{ lookup('vars', 'ansible_' + skylab_cluster.interface.access).ipv4.address | ansible.netcommon.ipaddr('host/prefix') }}"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
_node_addresses: "{{ _node_addresses + [item.address | ansible.netcommon.ipaddr('host/prefix')] }}"
|
|
|
|
loop: "{{ lookup('vars', 'ansible_' + skylab_cluster.interface.access).ipv4_secondaries }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.address }}"
|
|
|
|
|
|
|
|
- name: Determine cluster access addresses
|
|
|
|
run_once: true
|
|
|
|
vars:
|
|
|
|
_cluster_node_ips: []
|
|
|
|
ansible.builtin.set_fact:
|
2021-11-14 00:24:59 +00:00
|
|
|
_cluster_node_ips: "{{ _cluster_node_ips + [hostvars[item].skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix')] }}"
|
2021-11-11 05:34:05 +00:00
|
|
|
loop: "{{ groups.cluster }}"
|
|
|
|
|
|
|
|
- name: Remove alternative node IPs
|
|
|
|
become: true
|
2021-11-14 00:24:59 +00:00
|
|
|
when: item in _cluster_node_ips and item != (skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix'))
|
2021-11-11 05:34:05 +00:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: ip address delete {{ item | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
|
|
|
changed_when: true
|
|
|
|
loop: "{{ _node_addresses }}"
|
|
|
|
|
|
|
|
- name: Add node IP
|
|
|
|
become: true
|
2021-11-14 00:24:59 +00:00
|
|
|
when: skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') not in _node_addresses
|
2021-11-11 05:34:05 +00:00
|
|
|
ansible.builtin.command:
|
2021-11-14 00:24:59 +00:00
|
|
|
cmd: ip address add {{ skylab_cluster.address.access | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
2021-11-11 05:34:05 +00:00
|
|
|
changed_when: true
|