hecate: hydrate missing ssh inventory in host configs
This commit is contained in:
parent
89f4561a44
commit
27758d37c8
@ -90,6 +90,99 @@ migrate_hecate_config() {
|
||||
|
||||
local role
|
||||
role="$(read_hecate_role)"
|
||||
local inventory_block
|
||||
local managed_block
|
||||
if [[ "${role}" == "coordinator" ]]; then
|
||||
inventory_block='ssh_node_hosts:
|
||||
titan-db: 192.168.22.10
|
||||
titan-0a: 192.168.22.11
|
||||
titan-0b: 192.168.22.12
|
||||
titan-0c: 192.168.22.13
|
||||
titan-04: 192.168.22.30
|
||||
titan-05: 192.168.22.31
|
||||
titan-06: 192.168.22.32
|
||||
titan-07: 192.168.22.33
|
||||
titan-08: 192.168.22.34
|
||||
titan-09: 192.168.22.35
|
||||
titan-10: 192.168.22.36
|
||||
titan-11: 192.168.22.37
|
||||
titan-12: 192.168.22.40
|
||||
titan-13: 192.168.22.41
|
||||
titan-14: 192.168.22.42
|
||||
titan-15: 192.168.22.43
|
||||
titan-17: 192.168.22.45
|
||||
titan-18: 192.168.22.46
|
||||
titan-19: 192.168.22.47
|
||||
titan-20: 192.168.22.20
|
||||
titan-21: 192.168.22.21
|
||||
titan-22: 192.168.22.22
|
||||
titan-24: 192.168.22.26'
|
||||
managed_block='ssh_managed_nodes:
|
||||
- titan-db
|
||||
- titan-0a
|
||||
- titan-0b
|
||||
- titan-0c
|
||||
- titan-12
|
||||
- titan-14
|
||||
- titan-15
|
||||
- titan-17
|
||||
- titan-18
|
||||
- titan-22'
|
||||
elif [[ "${role}" == "peer" ]]; then
|
||||
inventory_block='ssh_node_hosts:
|
||||
titan-db: 192.168.22.10
|
||||
titan-0a: 192.168.22.11
|
||||
titan-0b: 192.168.22.12
|
||||
titan-0c: 192.168.22.13
|
||||
titan-04: 192.168.22.30
|
||||
titan-05: 192.168.22.31
|
||||
titan-06: 192.168.22.32
|
||||
titan-07: 192.168.22.33
|
||||
titan-08: 192.168.22.34
|
||||
titan-09: 192.168.22.35
|
||||
titan-10: 192.168.22.36
|
||||
titan-11: 192.168.22.37
|
||||
titan-12: 192.168.22.40
|
||||
titan-13: 192.168.22.41
|
||||
titan-14: 192.168.22.42
|
||||
titan-15: 192.168.22.43
|
||||
titan-17: 192.168.22.45
|
||||
titan-18: 192.168.22.46
|
||||
titan-19: 192.168.22.47
|
||||
titan-20: 192.168.22.20
|
||||
titan-21: 192.168.22.21
|
||||
titan-22: 192.168.22.22
|
||||
titan-24: 192.168.22.26'
|
||||
managed_block='ssh_managed_nodes:
|
||||
- titan-db
|
||||
- titan-0a
|
||||
- titan-0b
|
||||
- titan-0c
|
||||
- titan-12
|
||||
- titan-14
|
||||
- titan-15
|
||||
- titan-17
|
||||
- titan-18
|
||||
- titan-22
|
||||
- titan-24'
|
||||
fi
|
||||
|
||||
if [[ -n "${inventory_block}" ]]; then
|
||||
if grep -Eq '^ssh_node_hosts:[[:space:]]*\{\}[[:space:]]*$' "${CONF_DIR}/hecate.yaml"; then
|
||||
perl -0pi -e 's#ssh_node_hosts:\s*\{\}\n#'"${inventory_block}"'\n#s' "${CONF_DIR}/hecate.yaml"
|
||||
echo "[install] hydrated ssh_node_hosts inventory for role=${role}"
|
||||
changed=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${managed_block}" ]]; then
|
||||
if grep -Eq '^ssh_managed_nodes:[[:space:]]*\[\][[:space:]]*$' "${CONF_DIR}/hecate.yaml"; then
|
||||
perl -0pi -e 's#ssh_managed_nodes:\s*\[\]\n#'"${managed_block}"'\n#s' "${CONF_DIR}/hecate.yaml"
|
||||
echo "[install] hydrated ssh_managed_nodes inventory for role=${role}"
|
||||
changed=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${role}" == "peer" ]]; then
|
||||
if grep -Eq '^ssh_managed_nodes:[[:space:]]*$' "${CONF_DIR}/hecate.yaml" \
|
||||
&& grep -Eq '^ - titan-db$' "${CONF_DIR}/hecate.yaml" \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user