From 7ed9a75decfdf90a4474e4c7bbbcba4f398a20c1 Mon Sep 17 00:00:00 2001 From: Bill Buchan Date: Tue, 5 Nov 2024 14:28:14 +0000 Subject: [PATCH] Update password fetching for MP --- .../ME#24#STANDBY_PARAMETER_COMPARISON.xml | 2 +- .../standby_parameter_comparison/mea.xml | 2 +- .../ME#24#STANDBY_PARAMETER_COMPARISON.xml | 2 +- .../scripts/compare_parameters.sh | 43 ++++++++++++++++--- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/collection/ME#24#STANDBY_PARAMETER_COMPARISON.xml b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/collection/ME#24#STANDBY_PARAMETER_COMPARISON.xml index 10c9a5266..e0ef324a6 100644 --- a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/collection/ME#24#STANDBY_PARAMETER_COMPARISON.xml +++ b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/collection/ME#24#STANDBY_PARAMETER_COMPARISON.xml @@ -1,4 +1,4 @@ - + diff --git a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/mea.xml b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/mea.xml index 6d9f6e877..a135748df 100644 --- a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/mea.xml +++ b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/mea.xml @@ -1,5 +1,5 @@ - + diff --git a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/metadata/ME#24#STANDBY_PARAMETER_COMPARISON.xml b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/metadata/ME#24#STANDBY_PARAMETER_COMPARISON.xml index ada59338e..7c802905c 100644 --- a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/metadata/ME#24#STANDBY_PARAMETER_COMPARISON.xml +++ b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/metadata/ME#24#STANDBY_PARAMETER_COMPARISON.xml @@ -1,4 +1,4 @@ - + Ensure Database Instance Parameters match between Primary and Standby diff --git a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/scripts/compare_parameters.sh b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/scripts/compare_parameters.sh index 892fcf932..5d39fef28 100644 --- a/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/scripts/compare_parameters.sh +++ b/ansible/roles/oracle-oms-setup/files/metric_extensions/common/standby_parameter_comparison/scripts/compare_parameters.sh @@ -7,10 +7,32 @@ . ~/.bash_profile + +# If run on an instance hosting OEM we need to explicitly set up the database environment +if grep "^EMREP:" /etc/oratab > /dev/null; then + export ORAENV_ASK=NO + export ORACLE_SID=EMREP + . oraenv >/dev/null +fi + function get_password() { USERNAME=$1 -. /etc/environment && aws ssm get-parameters --region ${REGION} --with-decryption --name /${HMPPS_ENVIRONMENT}/${APPLICATION}/${HMPPS_ROLE}-database/db/oradb_${USERNAME,,}_password | jq -r '.Parameters[].Value' +if [[ "${ORACLE_SID}" == "EMREP" ]]; +then + aws secretsmanager get-secret-value --secret-id "/oracle/database/EMREP/passwords" --region eu-west-2 --query SecretString --output text| jq -r .${USERNAME} +else + INSTANCEID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) + APPLICATION=$(aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCEID}" "Name=key,Values=application" --query "Tags[].Value" --output text) + DELIUS_ENVIRONMENT=$(aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCEID}" "Name=key,Values=delius-environment" --query "Tags[].Value" --output text) + if [[ "${APPLICATION}" == "delius" ]]; + then + aws secretsmanager get-secret-value --secret-id delius-core-${DELIUS_ENVIRONMENT}-oracle-db-dba-passwords --region eu-west-2 --query SecretString --output text| jq -r .${USERNAME} + else + APPLICATION_SUBTYPE=$(aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCEID}" "Name=key,Values=database" --query "Tags[].Value" --output text | cut -d'_' -f1) + aws secretsmanager get-secret-value --secret-id ${APPLICATION}-${DELIUS_ENVIRONMENT}-oracle-${APPLICATION_SUBTYPE}-db-dba-passwords --region eu-west-2 --query SecretString --output text| jq -r .${USERNAME} + fi +fi } function get_jdbc() @@ -249,7 +271,10 @@ SELECT FROM parameter_comparison e WHERE - e.parameter_match != 'Y'; + e.parameter_match != 'Y' +AND + e.name != '_bug32914795_bct_last_dba_buffer_size'; -- See MOS Note 3049433.1 + EXIT EOSQL @@ -258,7 +283,13 @@ EOSQL DBSNMP_PASSWORD=$(get_password dbsnmp) SYS_PASSWORD=$(get_password sys) -for DB in $(echo -e "show configuration;" | dgmgrl / | grep "standby database" | cut -d'-' -f1) -do - report_differences ${ORACLE_SID} ${DB^^} -done \ No newline at end of file +# We check that the ORACLE_SID is the primary database as we only want to run this check against the primary +PRIMARY_SID=$(echo -e "show configuration;" | dgmgrl / | grep "Primary database" | cut -d'-' -f1 | sed 's/ //g' | tr '[:upper:]' '[:lower:]') + +if [[ "${ORACLE_SID,,}" == "${PRIMARY_SID}" ]]; +then + for DB in $(echo -e "show configuration;" | dgmgrl / | grep "standby database" | cut -d'-' -f1) + do + report_differences ${ORACLE_SID} ${DB^^} + done +fi \ No newline at end of file