From 206415ebe22d5fb32717c43f4a8aa07f4d8e3564 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Wed, 13 Sep 2023 10:09:02 +0200 Subject: [PATCH] fixup --- ansible/common.sh | 17 ++++++++++++++++- ansible/molecule/molecule.sh | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ansible/common.sh b/ansible/common.sh index 7f81892..ace4e8a 100755 --- a/ansible/common.sh +++ b/ansible/common.sh @@ -27,10 +27,25 @@ configureAnsible() { loadJBossNetworkAPISecrets() { if [ -e "${JBOSS_NETWORK_API_CREDENTIAL_FILE}" ]; then # extra spaces in front of -e is to prevent its interpretation as an arg of echo - echo ' -e' rhn_username="$(readValueFromFile 'rhn_username' ${JBOSS_NETWORK_API_CREDENTIAL_FILE})" -e rhn_password="$(readValueFromFile 'rhn_password' ${JBOSS_NETWORK_API_CREDENTIAL_FILE}) -e omit_rhn_output=false" + echo ' -e' rhn_username="$(readRHNUsername)" -e rhn_password="$(readRHNPassword) -e omit_rhn_output=false" fi } +readValueFromField() { + local field_name=${1} + local cred_file=${2:-"${JBOSS_NETWORK_API_CREDENTIAL_FILE}"} + + readValueFromFile "${field_name}" "${cred_file}" +} + +readRHNUsername() { + readValueFromField 'rhn_username' +} + +readRHNPassword() { + readValueFromField 'rhn_password' +} + readValueFromFile() { local field=${1} local file=${2} diff --git a/ansible/molecule/molecule.sh b/ansible/molecule/molecule.sh index e68a374..4092fdf 100755 --- a/ansible/molecule/molecule.sh +++ b/ansible/molecule/molecule.sh @@ -32,6 +32,8 @@ done # shellcheck disable=SC2155 readonly EXTRA_ARGS="$(loadJBossNetworkAPISecrets)" export EXTRA_ARGS +export REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID=$(readRHNUsername) +export REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET=$(readRHNPassord) printEnv echo "Running Molecule test on project: ${JOB_NAME}..."