Skip to content

Commit 435387d

Browse files
committed
Add WORKSPACES_DIR parameter to vars.yaml and update script references
1 parent c63b6b3 commit 435387d

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

scripts/sap_automation_qa.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ validate_params() {
178178
log "ERROR" "Error: The following parameters cannot be empty: ${missing_params[*]}"
179179
exit 1
180180
fi
181+
182+
WORKSPACES_DIR=$(grep "^WORKSPACES_DIR:" "$VARS_FILE" | awk '{split($0,a,": "); print a[2]}' | xargs)
183+
if [[ -z "$WORKSPACES_DIR" ]]; then
184+
WORKSPACES_DIR="WORKSPACES"
185+
log "INFO" "WORKSPACES_DIR not set in vars.yaml, using default: $WORKSPACES_DIR"
186+
else
187+
log "INFO" "WORKSPACES_DIR: $WORKSPACES_DIR"
188+
fi
189+
export WORKSPACES_DIR
181190
}
182191

183192
# Extract the error message from a command's output.
@@ -403,7 +412,7 @@ run_ansible_playbook() {
403412
command="ansible-playbook ${cmd_dir}/../src/$playbook_name.yml -i $system_hosts --private-key $temp_file \
404413
-e @$VARS_FILE -e @$system_params -e '_workspace_directory=$system_config_folder' $extra_vars"
405414
else
406-
local ssh_key_dir="${cmd_dir}/../WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME"
415+
local ssh_key_dir="${cmd_dir}/../$WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME"
407416
local ssh_key=""
408417
local extensions=("ppk" "pem" "key" "private" "rsa" "ed25519" "ecdsa" "dsa" "")
409418

@@ -429,7 +438,7 @@ run_ansible_playbook() {
429438
fi
430439

431440
check_file_exists "$ssh_key" \
432-
"SSH key file not found in WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME directory. Looked for files with patterns: ssh_key.*, *ssh_key*"
441+
"SSH key file not found in $WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME directory. Looked for files with patterns: ssh_key.*, *ssh_key*"
433442

434443
chmod 600 "$ssh_key"
435444
command="ansible-playbook ${cmd_dir}/../src/$playbook_name.yml -i $system_hosts --private-key $ssh_key \
@@ -449,9 +458,9 @@ run_ansible_playbook() {
449458
--extra-vars 'ansible_ssh_pass=$(cat $temp_file)' --extra-vars @$VARS_FILE -e @$system_params \
450459
-e '_workspace_directory=$system_config_folder' $extra_vars"
451460
else
452-
local password_file="${cmd_dir}/../WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME/password"
461+
local password_file="${cmd_dir}/../$WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME/password"
453462
check_file_exists "$password_file" \
454-
"password file not found in WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME directory."
463+
"password file not found in $WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME directory."
455464
command="ansible-playbook ${cmd_dir}/../src/$playbook_name.yml -i $system_hosts \
456465
--extra-vars 'ansible_ssh_pass=$(cat $password_file)' --extra-vars @$VARS_FILE -e @$system_params \
457466
-e '_workspace_directory=$system_config_folder' $extra_vars"
@@ -509,7 +518,7 @@ main() {
509518
validate_params
510519

511520
# Check if the SYSTEM_HOSTS and SYSTEM_PARAMS directory exists inside WORKSPACES/SYSTEM folder
512-
SYSTEM_CONFIG_FOLDER="${cmd_dir}/../WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME"
521+
SYSTEM_CONFIG_FOLDER="${cmd_dir}/../$WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME"
513522
SYSTEM_HOSTS="$SYSTEM_CONFIG_FOLDER/hosts.yaml"
514523
SYSTEM_PARAMS="$SYSTEM_CONFIG_FOLDER/sap-parameters.yaml"
515524
TEST_TIER=$(echo "$TEST_TIER" | tr '[:upper:]' '[:lower:]')
@@ -519,9 +528,9 @@ main() {
519528
log "INFO" "Using Authentication Type: $AUTHENTICATION_TYPE."
520529

521530
check_file_exists "$SYSTEM_HOSTS" \
522-
"hosts.yaml not found in WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME directory."
531+
"hosts.yaml not found in $WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME directory."
523532
check_file_exists "$SYSTEM_PARAMS" \
524-
"sap-parameters.yaml not found in WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME directory."
533+
"sap-parameters.yaml not found in $WORKSPACES_DIR/SYSTEM/$SYSTEM_CONFIG_NAME directory."
525534

526535
if [[ "$OFFLINE_MODE" == "true" ]]; then
527536
local crm_report_dir="$SYSTEM_CONFIG_FOLDER/offline_validation"

vars.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ SAP_FUNCTIONAL_TEST_TYPE: DatabaseHighAvailability
1515
# SAP System Configuration
1616
# String: Name of the SAP system configuration to be tested (Location: WORKSPACES/SYSTEM/DEV-WEEU-SAP01-X00 directory)
1717
SYSTEM_CONFIG_NAME: DEV-WEEU-SAP01-X00
18+
19+
# Workspaces Directory
20+
# String: Directory containing the WORKSPACES (default: WORKSPACES)
21+
WORKSPACES_DIR: WORKSPACES
22+
1823
# Choose the type of authentication you configured for a local account on the SAP VMs.
1924
# String: VMPASSWORD SSHKEY
2025
AUTHENTICATION_TYPE: SSHKEY

0 commit comments

Comments
 (0)