Compare commits

...

5 Commits

5 changed files with 78 additions and 2 deletions

56
playbooks/node-up.yaml Normal file
View File

@ -0,0 +1,56 @@
---
- 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:
_cluster_node_ips: "{{ _cluster_node_ips + [hostvars[item].skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix')] }}"
loop: "{{ groups.cluster }}"
- name: Remove alternative node IPs
become: true
when: item in _cluster_node_ips and item != (skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix'))
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
when: skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') not in _node_addresses
ansible.builtin.command:
cmd: ip address add {{ skylab_cluster.address | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
changed_when: true

View File

@ -14,6 +14,13 @@
path: /mnt/brick/datastore path: /mnt/brick/datastore
state: directory state: directory
- name: Start and disable glusterd
become: true
ansible.builtin.systemd:
name: glusterd
state: started
enabled: false
- name: Fetch peer status - name: Fetch peer status
become: true become: true
ansible.builtin.command: ansible.builtin.command:

View File

@ -60,6 +60,7 @@
block: block:
- name: Prompt for decryption key - name: Prompt for decryption key
no_log: true no_log: true
when: skylab_datastore_encryption_password is not defined
ansible.builtin.pause: ansible.builtin.pause:
prompt: >- prompt: >-
Datastore device {{ inventory_hostname }}:/dev/{{ skylab_datastore_device }} is not Datastore device {{ inventory_hostname }}:/dev/{{ skylab_datastore_device }} is not
@ -73,7 +74,7 @@
device: /dev/{{ skylab_datastore_device }} device: /dev/{{ skylab_datastore_device }}
state: opened state: opened
name: brick name: brick
passphrase: "{{ _luks_decryption_key.user_input }}" passphrase: "{{ _luks_decryption_key.user_input | default(skylab_datastore_encryption_password) }}"
- name: Fetch updated block device information - name: Fetch updated block device information
ansible.builtin.command: ansible.builtin.command:

View File

@ -16,3 +16,9 @@
- name: Configure hostsfile - name: Configure hostsfile
when: skylab_direct_peers is defined when: skylab_direct_peers is defined
ansible.builtin.include_tasks: hosts.yaml ansible.builtin.include_tasks: hosts.yaml
- name: Enable tmpfs mount
become: true
ansible.builtin.systemd:
name: tmp.mount
enabled: true

View File

@ -30,6 +30,12 @@
remote_addrs: "{{ _docker_swarm_manager_addresses }}" remote_addrs: "{{ _docker_swarm_manager_addresses }}"
join_token: "{{ _docker_swarm_join_token.stdout.strip() }}" join_token: "{{ _docker_swarm_join_token.stdout.strip() }}"
- name: Fetch node swarm ID
ansible.builtin.command:
cmd: !unsafe docker info --format '{{ .Swarm.NodeID}}'
changed_when: false
register: _docker_node_id_raw
# For newly added nodes we don't want to have services be automatically scheduled on them # For newly added nodes we don't want to have services be automatically scheduled on them
# until the configuration is complete. The node-up playbook will be responsible for updating # until the configuration is complete. The node-up playbook will be responsible for updating
# the node to make it available in the cluster again # the node to make it available in the cluster again
@ -38,4 +44,4 @@
ansible_python_interpreter: "{{ skylab_ansible_venv }}/bin/python" ansible_python_interpreter: "{{ skylab_ansible_venv }}/bin/python"
community.docker.docker_node: community.docker.docker_node:
availability: drain availability: drain
hostname: "{{ skylab_hostname }}" hostname: "{{ _docker_node_id_raw.stdout.strip() }}"