Compare commits
2 Commits
20450332d4
...
eb569c05c7
Author | SHA1 | Date | |
---|---|---|---|
eb569c05c7 | |||
f178a7bf78 |
@ -34,21 +34,19 @@ en1:
|
||||
- server
|
||||
- datastore
|
||||
- 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:
|
||||
pegasus: # jupiter
|
||||
ansible_host: 10.42.101.100
|
||||
skylab_hostname: pegasus.skylab.enp.one
|
||||
skylab_legacy_names:
|
||||
- jupiter.net.enp.one
|
||||
- jupiter.svr.local
|
||||
skylab_description: Arbiter Node
|
||||
skylab_cluster:
|
||||
address: 10.42.101.10/24
|
||||
address:
|
||||
access: 10.42.101.10/24
|
||||
internal: 192.168.42.10/24
|
||||
interface:
|
||||
access: bond0
|
||||
internal: bond0.99
|
||||
@ -77,9 +75,14 @@ en1:
|
||||
saturn: # remus
|
||||
ansible_host: 10.42.101.110
|
||||
skylab_hostname: saturn.skylab.enp.one
|
||||
skylab_legacy_names:
|
||||
- remus.net.enp.one
|
||||
- remus.svr.local
|
||||
skylab_description: Operational Node
|
||||
skylab_cluster:
|
||||
address: 10.42.101.11/24
|
||||
address:
|
||||
access: 10.42.101.11/24
|
||||
internal: 192.168.42.20/24
|
||||
interface:
|
||||
access: bond0
|
||||
internal: bond0.99
|
||||
@ -108,9 +111,14 @@ en1:
|
||||
orion: # romulus
|
||||
ansible_host: 10.42.101.120
|
||||
skylab_hostname: orion.skylab.enp.one
|
||||
skylab_legacy_names:
|
||||
- romulus.net.enp.one
|
||||
- romulus.svr.local
|
||||
skylab_description: Operational Node
|
||||
skylab_cluster:
|
||||
address: 10.42.101.12/24
|
||||
address:
|
||||
access: 10.42.101.12/24
|
||||
internal: 192.168.42.30/24
|
||||
interface:
|
||||
access: bond0
|
||||
internal: bond0.99
|
||||
|
@ -59,7 +59,7 @@
|
||||
when: inventory_hostname != _target_node
|
||||
ansible.builtin.assert:
|
||||
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'
|
||||
fail_msg: >-
|
||||
ERROR: Node '{{ inventory_hostname }}' is already marked as unavailable. All cluster
|
||||
@ -115,15 +115,15 @@
|
||||
|
||||
- name: Delete address from node
|
||||
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:
|
||||
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
|
||||
|
||||
- name: Assign address to alt node
|
||||
delegate_to: "{{ _target_alt }}"
|
||||
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:
|
||||
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
|
||||
|
@ -37,12 +37,12 @@
|
||||
vars:
|
||||
_cluster_node_ips: []
|
||||
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 }}"
|
||||
|
||||
- name: Remove alternative node IPs
|
||||
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:
|
||||
cmd: ip address delete {{ item | ansible.netcommon.ipaddr('host/prefix') }} dev {{ skylab_cluster.interface.access }}
|
||||
changed_when: true
|
||||
@ -50,7 +50,7 @@
|
||||
|
||||
- name: Add node IP
|
||||
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:
|
||||
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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
62
roles/swarm/tasks/gluster.yaml
Normal file
62
roles/swarm/tasks/gluster.yaml
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
- name: Fetch glusterfs plugin state
|
||||
block:
|
||||
- name: Fetch glusterfs storage plugin state
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin inspect glusterfs
|
||||
changed_when: false
|
||||
register: _docker_glusterfs_storage_plugin_raw
|
||||
rescue:
|
||||
- name: Install glusterfs storage plugin
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin install --alias glusterfs mochoa/glusterfs-volume-plugin --grant-all-permissions --disable
|
||||
changed_when: true
|
||||
|
||||
- name: Fetch glusterfs storage plugin state
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin inspect glusterfs
|
||||
changed_when: false
|
||||
register: _docker_glusterfs_storage_plugin_raw
|
||||
|
||||
- name: Process glusterfs storage plugin config
|
||||
ansible.builtin.set_fact:
|
||||
_docker_glusterfs_storage_plugin: "{{ (_docker_glusterfs_storage_plugin_raw.stdout | from_json)[0] }}"
|
||||
|
||||
# Note that this might not end up being defined if the plugin has not been configured
|
||||
- name: Identify plugin server settings
|
||||
when: item.startswith('SERVERS')
|
||||
ansible.builtin.set_fact:
|
||||
_docker_glusterfs_existing_setting: "{{ item }}"
|
||||
loop: "{{ _docker_glusterfs_storage_plugin.Settings.Env }}"
|
||||
|
||||
- name: Determine gluster servers
|
||||
run_once: true
|
||||
when: "'datastore' in hostvars[item].skylab_roles | default([])"
|
||||
vars:
|
||||
_docker_glusterfs_hostnames: []
|
||||
ansible.builtin.set_fact:
|
||||
_docker_glusterfs_hostnames: "{{ _docker_glusterfs_hostnames + [item + '.local'] }}"
|
||||
loop: "{{ groups.cluster }}"
|
||||
|
||||
- name: Determine gluster plugin setting
|
||||
ansible.builtin.set_fact:
|
||||
_docker_glusterfs_setting: "SERVERS={{ _docker_glusterfs_hostnames | join(',') }}"
|
||||
|
||||
- name: Configure plugin
|
||||
when: _docker_glusterfs_setting != _docker_glusterfs_existing_setting
|
||||
block:
|
||||
- name: Disable plugin
|
||||
when: _docker_glusterfs_storage_plugin.Enabled
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin disable glusterfs
|
||||
|
||||
- name: Set plugin servers setting
|
||||
changed_when: true
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin set glusterfs {{ _docker_glusterfs_setting }}
|
||||
register: _docker_glusterfs_set_setting
|
||||
|
||||
- name: Enable plugin
|
||||
when: not _docker_glusterfs_storage_plugin.Enabled or _docker_glusterfs_set_setting.changed | default(false)
|
||||
ansible.builtin.command:
|
||||
cmd: docker plugin enable glusterfs
|
@ -16,3 +16,6 @@
|
||||
- name: Join server to swarm
|
||||
when: _docker_swarm_needs_join
|
||||
ansible.builtin.include_tasks: join.yaml
|
||||
|
||||
- name: Configure gluster storage driver
|
||||
ansible.builtin.import_tasks: gluster.yaml
|
||||
|
Reference in New Issue
Block a user