From 069bf11ec6852e013f2859db36679305087a38da Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Fri, 23 Aug 2024 19:06:14 +0000 Subject: [PATCH 1/6] orahost_meta: Added default for oracle_install_option_gi to limit dependency to other roles --- changelogs/fragments/orahost_meta_gi.yml | 3 +++ roles/orahost_meta/tasks/assert_cluster.yml | 2 +- roles/orahost_meta/tasks/main.yml | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/orahost_meta_gi.yml diff --git a/changelogs/fragments/orahost_meta_gi.yml b/changelogs/fragments/orahost_meta_gi.yml new file mode 100644 index 000000000..bc626372f --- /dev/null +++ b/changelogs/fragments/orahost_meta_gi.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "orahost_meta: Added default for oracle_install_option_gi to limit dependency to other roles (oravirt#467)" diff --git a/roles/orahost_meta/tasks/assert_cluster.yml b/roles/orahost_meta/tasks/assert_cluster.yml index dbec84c7e..917231990 100644 --- a/roles/orahost_meta/tasks/assert_cluster.yml +++ b/roles/orahost_meta/tasks/assert_cluster.yml @@ -6,7 +6,7 @@ block: - name: assert orasw_meta_cluster_hostgroup (GI enabled) when: - - oracle_install_option_gi == 'CRS_CONFIG' + - oracle_install_option_gi | default('') == 'CRS_CONFIG' block: - name: assert orasw_meta_cluster_hostgroup ansible.builtin.assert: diff --git a/roles/orahost_meta/tasks/main.yml b/roles/orahost_meta/tasks/main.yml index fd7e85a26..b00088799 100644 --- a/roles/orahost_meta/tasks/main.yml +++ b/roles/orahost_meta/tasks/main.yml @@ -9,7 +9,7 @@ ansible.builtin.set_fact: _orasw_meta_primary_node: true when: - - oracle_install_option_gi != 'CRS_CONFIG' + - oracle_install_option_gi | default('') != 'CRS_CONFIG' # RAC: # 1st Node: @@ -20,7 +20,7 @@ ansible.builtin.set_fact: _orasw_meta_primary_node: "{{ groups[orasw_meta_cluster_hostgroup][0] == inventory_hostname }}" when: - - oracle_install_option_gi == 'CRS_CONFIG' + - oracle_install_option_gi | default('') == 'CRS_CONFIG' ### Determine kernel.panic according to Doc ID 2821641.1 # kdump state cannot savely be retrieved from service_facts From 6ae267c3694ef1d35dde377f4ad4e593acdab132 Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Sat, 24 Aug 2024 14:04:22 +0000 Subject: [PATCH 2/6] ocenv: version 2024-08-23 of ocenv environment script --- changelogs/fragments/ocenv.yml | 3 + roles/oradb_manage_db/files/ocenv | 328 +++++++++++++++++++++++++++--- 2 files changed, 298 insertions(+), 33 deletions(-) create mode 100644 changelogs/fragments/ocenv.yml diff --git a/changelogs/fragments/ocenv.yml b/changelogs/fragments/ocenv.yml new file mode 100644 index 000000000..b95312d72 --- /dev/null +++ b/changelogs/fragments/ocenv.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "ocenv: version 2024-08-23 of ocenv environment script (oravirt#468)" diff --git a/roles/oradb_manage_db/files/ocenv b/roles/oradb_manage_db/files/ocenv index 13e24bfd5..db8cb8eb3 100644 --- a/roles/oradb_manage_db/files/ocenv +++ b/roles/oradb_manage_db/files/ocenv @@ -1,5 +1,13 @@ #!/usr/bin/env bash +## Allow debugging of script, including line-number information and runtime-information +## We use "²" as delimiter, to allow separation of the output (e.g. in Excel) +if [[ "$1" == --debug ]] +then + export PS4='+ ²$(date "+%s.%N")²$LINENO² ' + set -x +fi + # Bash script to configure the environment for an Oracle DBA # Copyright (C) 2021 OPITZ CONSULTING Deutschland GmbH # @@ -31,7 +39,7 @@ ################################################################################ ## Version of this script. Simply uses the date in YYYY-MM-DD format -GV_OCENV_VERSION="2023-06-06" +GV_OCENV_VERSION="2024-08-23" ############################################################################### ## Environment support homogenization @@ -128,9 +136,11 @@ if [[ -d "${GV_SCRIPT_DIR}" ]] GV_BIN_DIR=${GV_SCRIPT_DIR}/bin/ if [[ -d ${GV_BIN_DIR} ]]; then export PATH="${GV_BIN_DIR}:${PATH}"; fi fi + # On AIX, this allows the installation of GNU-Tools (and rlwrap) via # the IBM Open Source Toolbox if [[ -d "/opt/freeware/bin/" ]]; then export PATH="/opt/freeware/bin/:${PATH}"; fi + if [[ -z "${GV_INITIAL_VARS_SAVED}" ]] then export ORIGINAL_SQLPATH_PRE_ENVLOAD="${SQLPATH}" @@ -143,8 +153,21 @@ then declare -a GV_ENV_SPECIFIC_VARS fi -export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 -export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" +set_nls_env_vars() { + if [[ -n "${GV_NLS_LANG}" ]] + then + export NLS_LANG="${GV_NLS_LANG}" + else + export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 + fi + if [[ -n "${GV_NLS_DATE_FORMAT}" ]] + then + export NLS_DATE_FORMAT="${GV_NLS_DATE_FORMAT}" + else + export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" + fi +} +set_nls_env_vars envhelp() { cat < "${GV_SQL_DIR}/login.sql" <<-"EOT" SET TAB OFF SET TERMOUT ON EOT +if [[ -f "${GV_CUSTOM_LOGIN_SQL}" ]] +then + echo "@${GV_CUSTOM_LOGIN_SQL}" >> "${GV_SQL_DIR}/login.sql" +fi alias cdh='cd ${ORACLE_HOME}' unalias cdt 2>/dev/null @@ -608,6 +656,11 @@ clroraenv() { unset GV_DB_ROLE unset GV_DB_UNIQUE_NAME_LC unset GV_DB_UNIQUE_NAME + unset GV_DB_VERSION + unset GV_DB_COMPATIBLE + unset GV_COMPAT_COLOR + unset GV_COMPAT_HINT + unset GV_COMPAT_MSG unset GV_INSTANCE_ALERT_LOG unset GV_INSTANCE_BDUMP_DEST unset GV_INSTANCE_DIAGNOSTIC_DEST @@ -930,12 +983,48 @@ asmcmd(){ } unalias asmdu 2>/dev/null asmdu() { + while [[ "$#" -gt 0 ]] + do + case $1 in + "-mincreateage") + shift; + if [[ "$#" -gt 0 ]] + then + local LV_MINCAGE=$1 + else + echo "Parameter \"-mincreateage\" requires value as next parameter." 1>&2 + return 1 + fi + shift; + ;; + "-minmodifyage") + shift; + if [[ "$#" -gt 0 ]] + then + local LV_MINMAGE=$1 + else + echo "Parameter \"-minmodifyage\" requires value as next parameter." 1>&2 + return 1 + fi + shift; + ;; + *) + ## Removing leading "+" if present + typeset LV_BASEDIR="${1#+}" + shift; + ;; + esac + done + ## "${VARNAME+x}" returns "x" if variable VARNAME is set to anything, else it returns nothing + if [[ -n "${LV_MINCAGE+x}" && -n "${LV_MINMAGE+x}" ]] + then + echo "Providing both \"-mincreateage\" and \"-minmodifyage\" at the same time is not allowed." 1>&2 + return 1 + fi # Fred Denis -- denis@pythian.com -- 2016 # Jan Schnackenberg - jan.schnackenberg@opitz-consulting.com # - If no parameter specified, show a du of each DiskGroup # - If a parameter, print a du of each subdirectory - ## Removing leading "+" if present - typeset LV_BASEDIR="${1#+}" ## Forcing trailing "/" regardless if present or not LV_BASEDIR="${LV_BASEDIR%/}/" @@ -953,17 +1042,18 @@ asmdu() { # Manage parameters if [[ -z "${LV_BASEDIR%/}" ]] then # No directory provided, will check all the DG - LV_DG_LIST=$(asmcmd lsdg | grep -v State | awk '{print $NF}' | sed s'/\///') + LV_DG_LIST=$(asmcmd lsdg | grep -v State | awk '{print $NF}' | sed 's|/||' ) LV_LIST_SUBDIRS="No" # Do not show the subdirectories details if no directory is specified else - LV_DG_LIST=$(echo "${LV_BASEDIR}" | sed s'/\/.*$//g') + # + LV_DG_LIST="${LV_BASEDIR%%/*}" LV_LIST_SUBDIRS="YES" # Show the subdirectories details if directory is specified fi LV_DG_LIST="$(echo "${LV_DG_LIST}" | tr '\n' ' ')" # Show DG overview - asmcmd lsdg | sed s'/\/$//' | awk -v DG_LIST="${LV_DG_LIST}" -v W="${LC_WARNING}" -v C="${LC_CRITICAL}" ' + asmcmd lsdg | sed 's|/$||' | awk -v DG_LIST="${LV_DG_LIST}" -v W="${LC_WARNING}" -v C="${LC_CRITICAL}" ' BEGIN { COLOR_BEGIN = "\033[1;" ; COLOR_END = "\033[m" ; @@ -1000,6 +1090,18 @@ asmdu() { # Subdirs info if [[ ${LV_LIST_SUBDIRS} == "YES" ]] then + ## "${VARNAME+x}" returns "x" if variable VARNAME is set to anything, else it returns nothing + if [[ -n "${LV_MINCAGE+x}" ]] + then + printf "%s\n\n The following table only takes files into account that\n have been created more than %d days ago.%s\n\n\n" "${GV_T_RED}" "${LV_MINCAGE}" "${GV_CCLR}" + fi + + ## "${VARNAME+x}" returns "x" if variable VARNAME is set to anything, else it returns nothing + if [[ -n "${LV_MINMAGE+x}" ]] + then + printf "%s\n\n The following table only takes files into account that\n have been modified more than %d days ago.%s\n\n\n" "${GV_T_RED}" "${LV_MINMAGE}" "${GV_CCLR}" + fi + exec_asm_sql_data " COL base_path FORMAT A100 COL sub_item FORMAT A50 @@ -1029,6 +1131,10 @@ asmdu() { ) x, (SELECT group_number gnum, file_number filnum, type ftype, bytes/1024/1024 mbytes, redundancy FROM v\$asm_file + WHERE ( ${LV_MINCAGE:-0} = 0 + OR creation_date < (SYSDATE - ${LV_MINCAGE:-0})) + AND ( ${LV_MINMAGE:-0} = 0 + OR modification_date < (SYSDATE - ${LV_MINMAGE:-0})) ORDER BY group_number, file_number ) f WHERE x.filnum != 4294967295 @@ -1318,25 +1424,30 @@ gdf() { unalias vit 2>/dev/null vit() { unset LV_FILE_ARR + # widely unknown, this is a possible location if [[ -f ${HOME}/.tnsnames.ora ]] then LV_FILE_ARR[${#LV_FILE_ARR[@]}]="${HOME}/.tnsnames.ora" fi - if [[ -n "${TNS_ADMIN}" && -f ${TNS_ADMIN}/tnsnames.ora ]] + # TNS_ADMIN variable might be used to force a directory for SQLnet files + if [[ -n "${TNS_ADMIN}" && -f ${TNS_ADMIN}/tnsnames.ora ]] && ! in_list "${TNS_ADMIN}/tnsnames.ora" "${LV_FILE_ARR[@]}" then LV_FILE_ARR[${#LV_FILE_ARR[@]}]="${TNS_ADMIN}/tnsnames.ora" fi - if [[ -f /etc/tnsnames.ora ]] + # /etc/tnsnames.ora is seldomly used + if [[ -f /etc/tnsnames.ora ]] && ! in_list "/etc/tnsnames.ora" "${LV_FILE_ARR[@]}" then LV_FILE_ARR[${#LV_FILE_ARR[@]}]="/etc/tnsnames.ora" fi - if [[ -f ${ORACLE_HOME}/network/admin/tnsnames.ora ]] + # most installations still use this default path + if [[ -f ${ORACLE_HOME}/network/admin/tnsnames.ora ]] && ! in_list "${ORACLE_HOME}/network/admin/tnsnames.ora" "${LV_FILE_ARR[@]}" then LV_FILE_ARR[${#LV_FILE_ARR[@]}]="${ORACLE_HOME}/network/admin/tnsnames.ora" fi + # The following loop iterates over all ORACLE_HOMEs in the /etc/oratab while read -r LV_FILE do - if [[ -e "${LV_FILE}" ]] + if [[ -e "${LV_FILE}" ]] && ! in_list "${LV_FILE}" "${LV_FILE_ARR[@]}" then LV_FILE_ARR[${#LV_FILE_ARR[@]}]="${LV_FILE}" fi @@ -1437,7 +1548,18 @@ grplogs() { fi local LV_REGEXP="$1" shift - awk -v V_SEARCH_REGEX="${LV_REGEXP}" ' + ( + for LV_FILENAME in "$@" + do + echo "STARTING_WITH_NEW_FILE ${LV_FILENAME}" + if [[ ${LV_FILENAME} =~ ^.*\.gz$ ]] + then + gunzip --to-stdout "${LV_FILENAME}" + else + cat "${LV_FILENAME}" + fi + done + ) | awk -v V_SEARCH_REGEX="${LV_REGEXP}" ' function myprint(filename, linenumber, date, line) { printf("%-30s [%d][%s]: %s\n", filename, linenumber, date, line); @@ -1454,16 +1576,19 @@ grplogs() { v_date_printed = 0; v_date_NR = -1; } + /^STARTING_WITH_NEW_FILE / { + v_filename=$2 + } { if ( $0 ~ search_date_regex) { v_date = $0; v_date_printed = 0; v_date_NR = NR; } else if ( $0 ~ search_ora_regex ) { - myprint(FILENAME, NR, v_date, $0); + myprint(v_filename, NR, v_date, $0); } } - ' "$@" + ' } rotate_file() { local LV_SOURCE="$1" @@ -1797,6 +1922,12 @@ vilsnr(){ fi } fill_pdb_details_list () { + if [[ "${GV_DB_VERSION:0:6}" == "12.1.0" ]] + then + local LV_QUERY="SELECT name ||'|'|| open_mode ||'|'|| restricted ||'|'|| TO_CHAR(open_time, 'YYYY-MM-DD HH24:MI:SS') ||'|'|| 'N/A' FROM v\$pdbs WHERE name <> 'PDB\$SEED' ORDER BY name" + else + local LV_QUERY="SELECT name ||'|'|| open_mode ||'|'|| restricted ||'|'|| TO_CHAR(open_time, 'YYYY-MM-DD HH24:MI:SS') ||'|'|| DECODE(local_undo, 1, 'YES', 'NO') FROM v\$pdbs WHERE name <> 'PDB\$SEED' ORDER BY name" + fi unset GV_PDB_LIST_DETAILS if [[ "${GV_IS_CDB}" == "YES" ]] @@ -1804,7 +1935,7 @@ fill_pdb_details_list () { while read -r LV_PDB_ELEM do GV_PDB_LIST_DETAILS[${#GV_PDB_LIST_DETAILS[@]}]="${LV_PDB_ELEM}" - done <<< "$(exec_sql_data "SELECT name ||'|'|| open_mode ||'|'|| restricted ||'|'|| TO_CHAR(open_time, 'YYYY-MM-DD HH24:MI:SS') ||'|'|| DECODE(local_undo, 1, 'YES', 'NO') FROM v\$pdbs WHERE name <> 'PDB\$SEED' ORDER BY name")" + done <<< "$(exec_sql_data "${LV_QUERY}")" fi } list_pdbs() { @@ -1839,13 +1970,16 @@ get_sid_info() { unset GV_DB_ROLE 2>/dev/null unset GV_DB_FORCE_LOGGING 2>/dev/null unset GV_DB_FLASHBACK_ON 2>/dev/null + unset GV_DB_COMPATIBLE 2>/dev/null + unset GV_DB_VERSION 2>/dev/null GV_ORACLE_SID_LC="$(echo "${ORACLE_SID}" | to_lower)" export GV_ORACLE_SID_LC LV_ENV_VAR_QUERY="SET LINES 2000 PAGES 0 HEAD OFF FEEDBACK OFF WHENEVER SQLERROR CONTINUE; SELECT 'REAL'||'OUTPUT::export GV_INSTANCE_STATUS=\"'||status||'\"' FROM v\$instance; -SELECT 'REAL'||'OUTPUT::export GV_INSTANCE_STARTUP=\"'||TO_CHAR(startup_time, 'YYYY-MM-DD HH24:MI:SS')||'\"' FROM v\$instance;" +SELECT 'REAL'||'OUTPUT::export GV_INSTANCE_STARTUP=\"'||TO_CHAR(startup_time, 'YYYY-MM-DD HH24:MI:SS')||'\"' FROM v\$instance; +SELECT 'REAL'||'OUTPUT::export GV_DB_VERSION=\"'||version||'\"' FROM v\$instance;" if [[ "$(echo "${ORACLE_SID}" | cut -b1)" != "+" ]] then @@ -1882,6 +2016,7 @@ END; SELECT 'REAL'||'OUTPUT::export GV_INSTANCE_DIAGNOSTIC_DEST=\"'||value||'\"' FROM v\$parameter WHERE name = 'diagnostic_dest'; SELECT 'REAL'||'OUTPUT::export GV_INSTANCE_BDUMP_DEST=\"'||value||'\"' FROM v\$parameter WHERE name = 'background_dump_dest'; SELECT 'REAL'||'OUTPUT::export GV_DB_UNIQUE_NAME=\"'||value||'\"' FROM v\$parameter WHERE name = 'db_unique_name'; +SELECT 'REAL'||'OUTPUT::export GV_DB_COMPATIBLE=\"'||value||'\"' FROM v\$parameter WHERE name = 'compatible'; -- If instance is only 'STARTED' then this statement will fail. That's ok, the variable is already set -- correctly in this case. WHENEVER SQLERROR CONTINUE; @@ -1919,6 +2054,7 @@ SELECT 'x' FROM dual" if [[ -n "${LV_ENV_VAR_CMDS}" ]] then eval "$(echo "${LV_ENV_VAR_CMDS}" | grep '^export')" + check_compatible_param_value # shellcheck disable=2153 GV_DB_UNIQUE_NAME_LC="$(echo "${GV_DB_UNIQUE_NAME}" | to_lower)" export GV_DB_UNIQUE_NAME_LC @@ -1953,6 +2089,81 @@ print_pdb_listing() { echo "${LV_PDB_DETAIL}" | awk -F"|" '{printf(" %-15s %-10s %-10s %-19s %-10s\n", $1, $2, $3, $4, $5)}' done } +check_compatible_param_value() { + GV_COMPAT_COLOR="${GV_B_RED}" + GV_COMPAT_HINT=" (exec \"compatible_info\" for details)" + GV_COMPAT_MSG="Compatible parameter could not be evaluated, defaulting to status \"error\"." + if in_list "${GV_DB_VERSION:0:6}" "18.0.0" "19.0.0" "21.0.0" "23.0.0" + then + if [[ "${GV_DB_VERSION:0:6}" == "${GV_DB_COMPATIBLE}" ]] + then + GV_COMPAT_COLOR="${GV_B_GREEN}" + GV_COMPAT_HINT="" + GV_COMPAT_MSG="Compatible parameter is set as recommended." + elif [[ "${GV_DB_VERSION:0:3}" == "${GV_DB_COMPATIBLE:0:3}" ]] + then + GV_COMPAT_COLOR="${GV_B_YELLOW}" + GV_COMPAT_HINT=" (exec \"compatible_info\" for details)" + GV_COMPAT_MSG="Compatible has correct base version, but does not follow the recommendation of \".0.0\"." + elif [[ "${GV_DB_VERSION:0:3}" > "${GV_DB_COMPATIBLE:0:3}" ]] + then + GV_COMPAT_COLOR="${GV_B_RED}" + GV_COMPAT_HINT=" (exec \"compatible_info\" for details)" + GV_COMPAT_MSG="Compatible parameter is to a version older than the one of this ORACLE_HOME." + fi + elif in_list "${GV_DB_VERSION:0:6}" "10.1.0" "10.2.0" "11.1.0" "11.2.0" "12.1.0" "12.2.0" + then + if [[ "${GV_DB_VERSION:0:6}" == "${GV_DB_COMPATIBLE}" ]] + then + GV_COMPAT_COLOR="${GV_B_GREEN}" + GV_COMPAT_HINT="" + GV_COMPAT_MSG="Compatible parameter is set using 3 digits, which is sufficient." + elif [[ "${GV_DB_VERSION:0:6}.0.0" == "${GV_DB_COMPATIBLE}" ]] + then + GV_COMPAT_COLOR="${GV_B_GREEN}" + GV_COMPAT_HINT="" + GV_COMPAT_MSG="Compatible parameter is set as recommended." + elif [[ "${GV_DB_VERSION}" == "${GV_DB_COMPATIBLE}" ]] + then + GV_COMPAT_COLOR="${GV_B_GREEN}" + GV_COMPAT_HINT="" + GV_COMPAT_MSG="Compatible is set to exact version." + elif [[ "${GV_DB_VERSION:0:6}" == "${GV_DB_COMPATIBLE:0:6}" ]] + then + GV_COMPAT_COLOR="${GV_B_YELLOW}" + GV_COMPAT_HINT=" (exec \"compatible_info\" for details)" + GV_COMPAT_MSG="Compatible has correct base version, but does not follow the recommendation of \"..0.0.0\" or being equal to exact version." + elif [[ "${GV_DB_VERSION:0:3}" > "${GV_DB_COMPATIBLE:0:3}" ]] + then + GV_COMPAT_COLOR="${GV_B_RED}" + GV_COMPAT_HINT=" (exec \"compatible_info\" for details)" + GV_COMPAT_MSG="Compatible parameter is to a version older than the one of this ORACLE_HOME." + fi + fi +} +compatible_info() { + if [[ -z "${ORACLE_SID}" || -z "${GV_DB_VERSION}" || -z "${GV_DB_COMPATIBLE}" || -z "${GV_COMPAT_MSG}" ]] + then + echo "${GV_B_YELLOW}The environment is not set for an instance. Or it was not set using ocenv.${GV_CCLR}" + else + echo "===================================================================================" + echo "" + echo "DB VERSION : ${GV_DB_VERSION}" + echo "COMPATIBLE PARAMETER: ${GV_DB_COMPATIBLE}" + echo "" + echo "${GV_COMPAT_MSG}" + echo "" + echo "" + echo "For MOS ID detailing setting this parameter see:" + echo " https://support.oracle.com/epmos/faces/DocContentDisplay?id=733987.1" + echo "" + echo "" + echo "For more details regarding setting the compatible parameter see:" + echo " https://mikedietrichde.com/2019/04/17/when-and-how-should-you-change-compatible/" + echo "" + echo "===================================================================================" + fi +} unalias sta 2>/dev/null sta() { get_sid_info @@ -1961,6 +2172,7 @@ sta() { echo "INSTANCE STATUS : ${GV_INSTANCE_STATUS}" # shellcheck disable=2153 echo "INSTANCE START TIME : ${GV_INSTANCE_STARTUP}" + echo "COMPATIBLE PARAMETER: ${GV_COMPAT_COLOR}${GV_DB_COMPATIBLE}${GV_CCLR}${GV_COMPAT_HINT}" unset GV_PDB_LIST if [[ "$(echo "${ORACLE_SID}" | cut -b1)" != "+" ]] then @@ -2085,7 +2297,7 @@ list_homes() { ## if this is the GRID_HOME, then activate this environment now if [[ -n "${GV_GRID_HOME}" && "${LV_ORA_HOME_PATH}" == "${GV_GRID_HOME}" ]] then - eval "${LV_ORA_HOME_NAME}" + GV_GRID_HOME_NAME="${LV_ORA_HOME_NAME}" shopt -s expand_aliases fi fi @@ -2239,7 +2451,12 @@ list_sids() { done ## Not running instances from oratab typeset LV_SID_LIST - LV_SID_LIST=$(grep -v -e '^[[:space:]]*$' -e '^[[:space:]]*#' -e '^[*]:' /etc/oratab 2>/dev/null | sed 's/:.*$//g') + ## Exclude all lines that + ## - are empty + ## - contain only whitespace before a comment + ## - contain an "asterix" as ORACLE_SID (first entry in definition) + ## - contain the startup-flag "L" (can be used for TNS listener entries for startup-scripts) + LV_SID_LIST=$(grep -v -E -e '^[[:space:]]*$' -e '^[[:space:]]*#' -e '^[*]:' -e '^[^#:]+:[^:]+:L' /etc/oratab 2>/dev/null | sed 's/:.*$//g') for LV_SID in ${LV_SID_LIST} do if in_list "${LV_SID}" "${GV_ALIAS_LIST[@]}" @@ -2297,11 +2514,12 @@ list_sids() { done } list_listener() { - local LV_ORA_LSNR_HOME LV_ORA_LSNR_USER + local LV_ORA_LSNR_HOME LV_ORA_LSNR_USER LV_COMMENT # shellcheck disable=2009 # no pgrep on AIX LV_ORA_LSNR_LIST=$(ps -eo args | grep -E "tnslsnr[ ]+" | awk '{print $2}') for LV_ORA_LSNR_NAME in ${LV_ORA_LSNR_LIST} do + LV_COMMENT="(${GV_T_GREEN}up${GV_CCLR})" # shellcheck disable=2009 # no pgrep on AIX LV_ORA_LSNR_HOME="$(ps -eo args | grep -E "tnslsnr[ ]+${LV_ORA_LSNR_NAME}[ ]+" | awk '{print $1}' | sed 's|/bin/tnslsnr||')" # shellcheck disable=2009 # no pgrep on AIX @@ -2313,7 +2531,41 @@ list_listener() { fi generate_alias_for_listener "${LV_ORA_LSNR_NAME}" "${LV_ORA_LSNR_HOME}" GV_ALIAS_LIST[${#GV_ALIAS_LIST[@]}]="${LV_ORA_LSNR_NAME}" - printf "%-4s %-10s %-30s %s\n" "lsnr" "${LV_ORA_LSNR_USER}" "${LV_ORA_LSNR_NAME}" "${LV_ORA_LSNR_HOME}" + printf "%-5s %-10s %-16s %-25s %s\n" "lsnr" "${LV_ORA_LSNR_USER}" "${LV_ORA_LSNR_NAME}" "${LV_COMMENT}" "${LV_ORA_LSNR_HOME}" + done + + ## Read lines from /etc/oratab that contain the startup-flag "L" + ## and that are not commented + ## (can be used for TNS listener entries for startup-scripts) + LV_ORA_LSNR_LIST=$(grep -v -e '^[[:space:]]*$' -e '^[[:space:]]*#' -e '^[*]:' /etc/oratab 2>/dev/null | grep -E -e '^[^#:]+:[^:]+:L' | sed 's/:.*$//g') + for LV_ORA_LSNR_NAME in ${LV_ORA_LSNR_LIST} + do + if in_list "${LV_ORA_LSNR_NAME}" "${GV_ALIAS_LIST[@]}" + then + continue + fi + + typeset LV_ORATAB + LV_ORATAB="$(grep "^${LV_ORA_LSNR_NAME}:" /etc/oratab 2>/dev/null)" + LV_ORA_LSNR_HOME="$(echo "${LV_ORATAB}" | cut -d: -f2)" + LV_ORA_LSNR_USER="$(mystat "${LV_ORA_LSNR_HOME}")" + + local LV_COMMENT="(oratab,${GV_T_RED}down${GV_CCLR})" + if [[ -x "${LV_ORA_LSNR_HOME}/bin/oracle" ]] + then + LV_TYPE="lsnr" + else + LV_TYPE="unkn" + ## "dummy" format codes, to prevent problems with formatting in following printf + LV_COMMENT="${GV_T_WHITE}(oratab)${GV_CCLR}" + fi + ## Format-width for "COMMENT"-column adjusted for 12 (8+4) invisible format characters (see top of script) + printf "%-5s %-10s %-16s %-25s %s\n" "${LV_TYPE}" "${LV_ORA_LSNR_USER}" "${LV_ORA_LSNR_NAME}" "${LV_COMMENT}" "${LV_ORA_LSNR_HOME}" + if [[ "${LV_TYPE}" != "asm" ]] + then + generate_alias_for_listener "${LV_ORA_LSNR_NAME}" "${LV_ORA_LSNR_HOME}" + GV_ALIAS_LIST[${#GV_ALIAS_LIST[@]}]="${LV_ORA_LSNR_NAME}" + fi done } clear_aliases() { @@ -2364,7 +2616,7 @@ read_proxy() { printf " HTTPS_PROXY=\"%s\"\n" "${HTTPS_PROXY}" printf "Press to keep this unchanged\n" printf "\n" - read -r -p "Enter proxy (Format: [protocol://][:port]) to access git.opitz-consulting.com: " LV_PROXY_URL + read -r -p "Enter proxy (Format: [protocol://][:port]) to access internet servers: " LV_PROXY_URL if [[ -n "${LV_PROXY_URL}" ]] then export HTTPS_PROXY="${LV_PROXY_URL}" @@ -2412,6 +2664,16 @@ list_env() { list_homes list_sids list_listener + if [[ -n "${GV_DEFAULT_ENV_NAME}" ]] + then + if ! eval "${GV_DEFAULT_ENV_NAME}" + then + echo "Failed to source environment specified in variable \"GV_DEFAULT_ENV_NAME\" in ~/.ocenv" 1>&2 + fi + elif [[ -n "${GV_GRID_HOME_NAME}" ]] + then + eval "${GV_GRID_HOME_NAME}" + fi } show_env_version() { echo "#####################################################################################" From 970298a59ffd48f99c8ccd7a644e6199dd295fcf Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Tue, 27 Aug 2024 04:16:46 +0000 Subject: [PATCH 3/6] ansible-builder: moved to new base image The creator-ee images has been archived. Move to a new base image and build the execution environment from scratch with all python development tools in 1 container for ansible-oracle. --- changelogs/fragments/builder.yml | 3 +++ execution-environment.yml | 18 +++++++++++++----- tools/dev/requirements_dev.txt | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/builder.yml diff --git a/changelogs/fragments/builder.yml b/changelogs/fragments/builder.yml new file mode 100644 index 000000000..1f99eab8e --- /dev/null +++ b/changelogs/fragments/builder.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "ansible-builder: moved to new base image (oravirt#470)" diff --git a/execution-environment.yml b/execution-environment.yml index 78a0abaa8..895a454ec 100644 --- a/execution-environment.yml +++ b/execution-environment.yml @@ -3,10 +3,18 @@ version: 3 images: base_image: - name: ghcr.io/ansible/creator-ee:v24.2.0 - -options: - package_manager_path: /usr/bin/microdnf + name: quay.io/centos/centos:stream9 dependencies: - python: requirements.txt + python_interpreter: + package_system: python3.11 + python_path: /usr/bin/python3.11 + system: + - iputils + - openssh-clients + - less + ansible_core: + package_pip: ansible-core<2.17.0 + ansible_runner: + package_pip: ansible-runner==2.4.0 + python: tools/dev/requirements_dev.txt diff --git a/tools/dev/requirements_dev.txt b/tools/dev/requirements_dev.txt index 932aeec85..71eeb5b02 100644 --- a/tools/dev/requirements_dev.txt +++ b/tools/dev/requirements_dev.txt @@ -12,6 +12,7 @@ # . ~/venv/ansible-oracle/bin/activate # pip --require-virtualenv -v install -r tools/dev/requirements_dev.txt # +ansible-core<2.17 ansible-lint==6.22.1 ansible-navigator==3.4.0 pre-commit==3.4.0 From 9c89394e3139b8b1a89c14cd4f5ec6424fc6d16a Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Tue, 27 Aug 2024 04:16:52 +0000 Subject: [PATCH 4/6] tools: changed requirements_dev.txt for venv --- changelogs/fragments/builder.yml | 1 + tools/ansible/requirements_ansible.txt | 4 +--- tools/dev/requirements_dev.txt | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 120000 tools/ansible/requirements_ansible.txt diff --git a/changelogs/fragments/builder.yml b/changelogs/fragments/builder.yml index 1f99eab8e..6571e0bf1 100644 --- a/changelogs/fragments/builder.yml +++ b/changelogs/fragments/builder.yml @@ -1,3 +1,4 @@ --- minor_changes: - "ansible-builder: moved to new base image (oravirt#470)" + - "tools: changed requirements_dev.txt for venv (oravirt#470)" diff --git a/tools/ansible/requirements_ansible.txt b/tools/ansible/requirements_ansible.txt deleted file mode 100644 index 1806e76f1..000000000 --- a/tools/ansible/requirements_ansible.txt +++ /dev/null @@ -1,3 +0,0 @@ -# -ansible==8.5.0 -ansible-navigator==3.4.2 diff --git a/tools/ansible/requirements_ansible.txt b/tools/ansible/requirements_ansible.txt new file mode 120000 index 000000000..498bb718d --- /dev/null +++ b/tools/ansible/requirements_ansible.txt @@ -0,0 +1 @@ +../dev/requirements_dev.txt \ No newline at end of file diff --git a/tools/dev/requirements_dev.txt b/tools/dev/requirements_dev.txt index 71eeb5b02..aac063e5e 100644 --- a/tools/dev/requirements_dev.txt +++ b/tools/dev/requirements_dev.txt @@ -13,14 +13,15 @@ # pip --require-virtualenv -v install -r tools/dev/requirements_dev.txt # ansible-core<2.17 +ansible-builder==3.1.0 ansible-lint==6.22.1 -ansible-navigator==3.4.0 +ansible-navigator==24.8.0 pre-commit==3.4.0 # docker is needed by molecule docker==6.1.3 -molecule==5.1.0 -molecule-plugins[docker]==23.5.0 +molecule==24.8.0 +molecule-plugins[docker]==23.5.3 # xmltodict is needed for ansible.utils.keep_keys xmltodict==0.13.0 From e0ecfbeed219f8239841cfc57974f5ed0026ef69 Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Tue, 27 Aug 2024 15:23:39 +0000 Subject: [PATCH 5/6] ansible-lint: Update ansible-lint to 24.7.0 --- .github/workflows/ansible-lint.yml | 2 +- .pre-commit-config.yaml | 2 +- changelogs/fragments/ansible-lint.yml | 3 +++ tools/dev/requirements_dev.txt | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/ansible-lint.yml diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index fb71e3cbb..4f4a92880 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -18,4 +18,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: Run ansible-lint - uses: ansible/ansible-lint@v6.22.1 + uses: ansible/ansible-lint@v24.7.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 656ffe1d8..163bae6eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: - ansible-core - repo: https://github.com/ansible-community/ansible-lint.git - rev: v6.22.1 + rev: v24.7.0 hooks: - id: ansible-lint entry: ansible-lint --force-color -p diff --git a/changelogs/fragments/ansible-lint.yml b/changelogs/fragments/ansible-lint.yml new file mode 100644 index 000000000..f8f9a75e0 --- /dev/null +++ b/changelogs/fragments/ansible-lint.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "ansible-lint: Update ansible-lint to 24.7.0 (oravirt#471)" diff --git a/tools/dev/requirements_dev.txt b/tools/dev/requirements_dev.txt index aac063e5e..ab655e7c3 100644 --- a/tools/dev/requirements_dev.txt +++ b/tools/dev/requirements_dev.txt @@ -14,7 +14,7 @@ # ansible-core<2.17 ansible-builder==3.1.0 -ansible-lint==6.22.1 +ansible-lint==24.7.0 ansible-navigator==24.8.0 pre-commit==3.4.0 From 5fa72ae4111c5bfd47fbe9c432b743d1f85a925d Mon Sep 17 00:00:00 2001 From: Thorsten Bruhns Date: Tue, 27 Aug 2024 15:36:44 +0000 Subject: [PATCH 6/6] ansible-lint: fqcn[action-core] for ansible.builtin.yum due to OL7 compatibility --- changelogs/fragments/ansible-lint2.yml | 3 +++ example/rac/ansible/playbooks/os_racattack.yml | 4 ++-- roles/common/tasks/RedHat.yml | 4 ++-- roles/orahost/tasks/RedHat.yml | 6 +++--- roles/oraswgi_install/tasks/12.1.0.1.yml | 2 +- roles/oraswgi_install/tasks/12.1.0.2.yml | 2 +- roles/oraswgi_install/tasks/12.2.0.1.yml | 2 +- roles/oraswgi_install/tasks/18.3.0.0.yml | 2 +- roles/oraswgi_install/tasks/19.3.0.0.yml | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/ansible-lint2.yml diff --git a/changelogs/fragments/ansible-lint2.yml b/changelogs/fragments/ansible-lint2.yml new file mode 100644 index 000000000..3283eba60 --- /dev/null +++ b/changelogs/fragments/ansible-lint2.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "ansible-lint: fqcn[action-core] for ansible.builtin.yum due to OL7 compatibility (oravirt#471)" diff --git a/example/rac/ansible/playbooks/os_racattack.yml b/example/rac/ansible/playbooks/os_racattack.yml index a3c5aa452..75da150b0 100644 --- a/example/rac/ansible/playbooks/os_racattack.yml +++ b/example/rac/ansible/playbooks/os_racattack.yml @@ -28,7 +28,7 @@ {% endfor %} - name: List availible updates - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] list: updates update_cache: true security: true @@ -40,7 +40,7 @@ var: yum_update_list_res.results | map(attribute='name') | sort - name: Update all OS packages to latest - ansible.builtin.yum: # noqa: package-latest + ansible.builtin.yum: # noqa: package-latest fqcn[action-core] name: '*' state: latest lock_timeout: 600 diff --git a/roles/common/tasks/RedHat.yml b/roles/common/tasks/RedHat.yml index e17f98a82..a9ba1afd0 100644 --- a/roles/common/tasks/RedHat.yml +++ b/roles/common/tasks/RedHat.yml @@ -11,7 +11,7 @@ key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} - name: Add EPEL Repo - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ _common_epel_rpm }}" state: installed @@ -43,7 +43,7 @@ - olrepo - name: Install common packages OL/RHEL - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ common_packages }}" state: installed when: diff --git a/roles/orahost/tasks/RedHat.yml b/roles/orahost/tasks/RedHat.yml index 39c7719d1..a6f492b6f 100644 --- a/roles/orahost/tasks/RedHat.yml +++ b/roles/orahost/tasks/RedHat.yml @@ -1,7 +1,7 @@ --- # OL8/RHEL8 has all needed RPMs in orahost role! - name: Install packages required by Oracle on OL/RHEL version 6,7,8,9 - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_packages }}" state: installed enablerepo: "{{ extrarepos_enabled | default(omit, True) }}" @@ -13,7 +13,7 @@ notify: Reboot concerning package updates - name: Install packages required by Oracle for ASMlib on OL/RHEL - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_asm_packages }}" state: installed enablerepo: "{{ extrarepos_enabled | default(omit, True) }}" @@ -30,7 +30,7 @@ - disable_firewall block: - name: Check if firewall is installed - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] list: "{{ firewall_service }}" disablerepo: "*" tags: iptables,firewalld diff --git a/roles/oraswgi_install/tasks/12.1.0.1.yml b/roles/oraswgi_install/tasks/12.1.0.1.yml index 009f5cd75..40e2b6481 100644 --- a/roles/oraswgi_install/tasks/12.1.0.1.yml +++ b/roles/oraswgi_install/tasks/12.1.0.1.yml @@ -26,7 +26,7 @@ - name: install_home_gi | Install cvuqdisk rpm # noqa ignore-errors - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_stage_install }}/{{ oracle_install_version_gi }}/grid/rpm/{{ cvuqdisk_rpm }}" state: present when: _oraswgi_meta_configure_cluster diff --git a/roles/oraswgi_install/tasks/12.1.0.2.yml b/roles/oraswgi_install/tasks/12.1.0.2.yml index 9b75020f7..c42f92990 100644 --- a/roles/oraswgi_install/tasks/12.1.0.2.yml +++ b/roles/oraswgi_install/tasks/12.1.0.2.yml @@ -27,7 +27,7 @@ when: oracle_home_gi not in checkgiinstall.stdout and oracle_install_version_gi == item.version and not oracle_sw_copy and oracle_sw_unpack - name: install_home_gi | Install cvuqdisk rpm - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_stage_install }}/{{ oracle_install_version_gi }}/grid/rpm/{{ cvuqdisk_rpm }}" state: present # noqa ignore-errors diff --git a/roles/oraswgi_install/tasks/12.2.0.1.yml b/roles/oraswgi_install/tasks/12.2.0.1.yml index 120e8398c..d5dd11f65 100644 --- a/roles/oraswgi_install/tasks/12.2.0.1.yml +++ b/roles/oraswgi_install/tasks/12.2.0.1.yml @@ -49,7 +49,7 @@ - _orasw_meta_primary_node | bool - name: install_home_gi | Install cvuqdisk rpm - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_home_gi }}/cv/rpm/{{ cvuqdisk_rpm }}" state: present # noqa ignore-errors diff --git a/roles/oraswgi_install/tasks/18.3.0.0.yml b/roles/oraswgi_install/tasks/18.3.0.0.yml index b3bb9ab31..00b35340f 100644 --- a/roles/oraswgi_install/tasks/18.3.0.0.yml +++ b/roles/oraswgi_install/tasks/18.3.0.0.yml @@ -53,7 +53,7 @@ - _orasw_meta_primary_node | bool - name: install_home_gi | Install cvuqdisk rpm - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_home_gi }}/cv/rpm/{{ cvuqdisk_rpm }}" state: present # noqa ignore-errors diff --git a/roles/oraswgi_install/tasks/19.3.0.0.yml b/roles/oraswgi_install/tasks/19.3.0.0.yml index 817001aa5..908e9df03 100644 --- a/roles/oraswgi_install/tasks/19.3.0.0.yml +++ b/roles/oraswgi_install/tasks/19.3.0.0.yml @@ -98,7 +98,7 @@ tags: cvuqdisk - name: include 19c/21c | Install cvuqdisk rpm - ansible.builtin.yum: + ansible.builtin.yum: # noqa fqcn[action-core] name: "{{ oracle_rsp_stage }}/{{ cvuqdisk_rpm }}" state: present disable_gpg_check: true