From 2a59d0995c26f49345ffc1b5b4ec5605bce70afc Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 24 Apr 2023 14:48:56 +0200 Subject: [PATCH] Add nextcloud version knowledge --- facts.d/nc_versions.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 facts.d/nc_versions.sh diff --git a/facts.d/nc_versions.sh b/facts.d/nc_versions.sh new file mode 100755 index 0000000..38ce14f --- /dev/null +++ b/facts.d/nc_versions.sh @@ -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