Add nextcloud version knowledge

This commit is contained in:
Micke Nordin 2023-04-24 14:48:56 +02:00
parent c5e5279f0e
commit 2a59d0995c
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

29
facts.d/nc_versions.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
repo="/var/cache/cosmos/repo"
common="${repo}/global/overlay/etc/hiera/data/common.yaml"
function print_fact {
customer=${1}
environment=${2}
version=${3}
if [[ ${version} != 'null' ]]; then
echo "nextcloud_version_${environment}_${customer}=${version}"
else
echo "nextcloud_version_${environment}_${customer}=$(yq -r ".${key}" "${common}")"
fi
}
for environment in test prod; do
key="nextcloud_version_${environment}"
for customer in $(yq -r '.multinode_mapping | keys| .[]' "${common}"); do
group="${repo}/multinode-common/overlay/etc/hiera/data/group.yaml"
version=$(yq -r ".${key}" "${group}")
print_fact "${customer}" "${environment}" "${version}"
done
for customer in $(yq -r '.fullnodes[]' "${common}"); do
group="${repo}/${customer}-common/overlay/etc/hiera/data/group.yaml"
version=$(yq -r ".${key}" "${group}")
print_fact "${customer}" "${environment}" "${version}"
done
done