diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b069228..a8a1095 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,7 +4,7 @@ (Please provide relevant configs (Be sure to remove sensitive info).) ### Steps to Reproduce Issue -(Include debug logs if possible, `bootstrap-salt.sh -D`.) +(Include debug logs if possible, `svtminion.sh --debug`.) ### Versions and Systems (`salt --versions-report`, `svtminion.sh --version`, system type and version, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3905f4..cb50a8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: concurrency: # If changes are pushed to a PR, stop all running workflows before starting new ones - group: ${{ github.head_ref || (github.repository == 'saltstack/salt-bootstrap' && github.run_id || github.ref_name) }} + group: ${{ github.head_ref || (github.repository == 'saltstack/salt-vmtools' && github.run_id || github.ref_name) }} cancel-in-progress: true jobs: @@ -98,7 +98,7 @@ jobs: - uses: actions/checkout@v4 - name: ShellCheck run: | - shellcheck -s sh -f tty bootstrap-salt.sh + shellcheck -s bash -f tty linux/svtminion.sh - name: Set Exit Status if: always() @@ -114,6 +114,7 @@ jobs: path: exitstatus/ + windows-2022: name: Windows 2022 if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true' @@ -127,7 +128,8 @@ jobs: container-slug: windows-2022 timeout: 20 runs-on: windows-2022 - instances: '["stable-3006", "stable-3006-8", "stable-3007", "stable-3007-1", "latest"]' + instances: '["3006", "3006-8", "3007", "3007-1"]' + photon-5: @@ -142,7 +144,7 @@ jobs: display-name: Photon OS 5 container-slug: systemd-photon-5 timeout: 20 - instances: '["stable-3006", "onedir-3006", "stable-3006-8", "latest", "default"]' + instances: '["3006", "3006-8", "3007", "3007-1"]' rockylinux-9: @@ -157,22 +159,8 @@ jobs: display-name: Rocky Linux 9 container-slug: systemd-rockylinux-9 timeout: 20 - instances: '["stable-3006", "onedir-3006", "stable-3006-8", "stable-3007", "onedir-3007", "stable-3007-1", "git-master", "latest", "default"]' - + instances: '["3006", "3006-8", "3007", "3007-1"]' - ubuntu-2204: - name: Ubuntu 22.04 - if: github.event_name == 'push' || needs.collect-changed-files.outputs.run-tests == 'true' - uses: ./.github/workflows/test-linux.yml - needs: - - lint - - generate-actions-workflow - with: - distro-slug: ubuntu-2204 - display-name: Ubuntu 22.04 - container-slug: systemd-ubuntu-22.04 - timeout: 20 - instances: '["stable-3006", "onedir-3006", "stable-3006-8", "stable-3007", "onedir-3007", "stable-3007-1", "git-master", "latest", "default"]' set-pipeline-exit-status: # This step is just so we can make github require this step, to pass checks @@ -185,7 +173,6 @@ jobs: - windows-2022 - photon-5 - rockylinux-9 - - ubuntu-2204 if: always() steps: diff --git a/.github/workflows/scripts/cut-release.py b/.github/workflows/scripts/cut-release.py index 96b76c2..2a2a3b4 100644 --- a/.github/workflows/scripts/cut-release.py +++ b/.github/workflows/scripts/cut-release.py @@ -189,36 +189,36 @@ def main(): ) # Update Script Version for the bash script - bootstrap_script_path = REPO_ROOT / "bootstrap-salt.sh" + svtminion_script_path = REPO_ROOT / "linux/svtminion.sh" print( - f"* Updating {bootstrap_script_path.relative_to(REPO_ROOT)} ...", + f"* Updating {svtminion_script_path.relative_to(REPO_ROOT)} ...", file=sys.stderr, flush=True, ) - bootstrap_script_path.write_text( + svtminion_script_path.write_text( re.sub( r'__ScriptVersion="(.*)"', f'__ScriptVersion="{options.release_tag.lstrip("v")}"', - bootstrap_script_path.read_text(), + svtminion_script_path.read_text(), ) ) # Update the Script Version for the powershell script - bootstrap_script_path = REPO_ROOT / "bootstrap-salt.ps1" + svtminion_script_path = REPO_ROOT / "windows/svtminion.ps1" print( - f"* Updating {bootstrap_script_path.relative_to(REPO_ROOT)} ...", + f"* Updating {svtminion_script_path.relative_to(REPO_ROOT)} ...", file=sys.stderr, flush=True, ) - bootstrap_script_path.write_text( + svtminion_script_path.write_text( re.sub( r'\$__ScriptVersion = "(.*)"', f'$__ScriptVersion = "{options.release_tag.lstrip("v")}"', - bootstrap_script_path.read_text(), + svtminion_script_path.read_text(), ) ) - parser.exit(status=0, message="CHANGELOG.md and bootstrap-salt.sh updated\n") + parser.exit(status=0, message="CHANGELOG.md and svtminion.sh updated\n") if __name__ == "__main__": diff --git a/.github/workflows/templates/ci.yml b/.github/workflows/templates/ci.yml index 940ec8a..cd5bceb 100644 --- a/.github/workflows/templates/ci.yml +++ b/.github/workflows/templates/ci.yml @@ -5,7 +5,7 @@ on: concurrency: # If changes are pushed to a PR, stop all running workflows before starting new ones - group: ${{ github.head_ref || (github.repository == 'saltstack/salt-bootstrap' && github.run_id || github.ref_name) }} + group: ${{ github.head_ref || (github.repository == 'saltstack/salt-vmtools' && github.run_id || github.ref_name) }} cancel-in-progress: true jobs: @@ -98,7 +98,7 @@ jobs: - uses: actions/checkout@v4 - name: ShellCheck run: | - shellcheck -s sh -f tty bootstrap-salt.sh + shellcheck -s bash -f tty linux/svtminion.sh - name: Set Exit Status if: always() diff --git a/.github/workflows/templates/generate.py b/.github/workflows/templates/generate.py index a7b0113..67625a1 100755 --- a/.github/workflows/templates/generate.py +++ b/.github/workflows/templates/generate.py @@ -6,10 +6,10 @@ os.chdir(os.path.abspath(os.path.dirname(__file__))) +## "ubuntu-2204", LINUX_DISTROS = [ "photon-5", "rockylinux-9", - "ubuntu-2204", ] WINDOWS = [ @@ -43,17 +43,17 @@ LATEST_PKG_BLACKLIST = [] +## "ubuntu-2204": "Ubuntu 22.04", DISTRO_DISPLAY_NAMES = { "photon-5": "Photon OS 5", "rockylinux-9": "Rocky Linux 9", - "ubuntu-2204": "Ubuntu 22.04", "windows-2022": "Windows 2022", } +## "ubuntu-2204": "systemd-ubuntu-22.04", CONTAINER_SLUG_NAMES = { "photon-5": "systemd-photon-5", "rockylinux-9": "systemd-rockylinux-9", - "ubuntu-2204": "systemd-ubuntu-22.04", "windows-2022": "windows-2022", } @@ -94,6 +94,9 @@ def generate_test_jobs(): else TIMEOUT_DEFAULT ) + for salt_version in SALT_VERSIONS: + instances.append(salt_version) + if instances: needs.append(distro) test_jobs += TEMPLATE.format( diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 42a36cd..1a34b6c 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -73,7 +73,7 @@ jobs: ## echo "vt parms ,$vt_parms, vt_parms_ver ,$vt_parm_ver," ## echo "SaltVersion=$vt_parm_ver" >> $GITHUB_ENV - - name: Bootstrap Salt + - name: VMTools Salt run: | # sed 1st - becomes space, 2nd - becomes dot ## DGM needs cleanup @@ -82,10 +82,9 @@ jobs: bt_arg1=$(echo "$bt_parms" | awk -F ' ' '{print $1}') bt_arg2=$(echo "$bt_parms" | awk -F ' ' '{print $2}') echo "bt parms ,$bt_parms, bt_arg1 ,$bt_arg1, bt_arg2 ,$bt_arg2," - ## DGM sudo sh -x ./bootstrap-salt.sh "$bt_arg1" "$bt_arg2" bash -x ./linux/svtminion.sh "$bt_arg1" "$bt_arg2" - - name: Test Bootstrap + - name: Test VMTools run: | bash -x ./tests/linux/test-linux.sh diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 9515dae..f69527a 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -58,7 +58,7 @@ jobs: - name: Get Version run: | # We need to get the version here and make it an environment variable - # It is used to install via bootstrap and in the test + # It is used to install via svtminion and in the test # The version is in the instance name $instance = "${{ matrix.instance }}" $version = $instance -split "-",2 @@ -67,11 +67,11 @@ jobs: } Write-Output "SaltVersion=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Bootstrap Salt + - name: VMTools Salt run: | - . .\bootstrap-salt.ps1 -RunService $false -Version $env:SaltVersion + . .\windows\svtminion.ps1 -RunService $false -Version $env:SaltVersion - - name: Test Bootstrap + - name: Test svtminion run: | pytest --cache-clear -v -s -ra --log-cli-level=debug tests/integration/ diff --git a/linux/svtminion.sh b/linux/svtminion.sh index 3aa6414..da5687a 100755 --- a/linux/svtminion.sh +++ b/linux/svtminion.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Copyright 2021-2024 Broadcom Inc. # SPDX-License-Identifier: Apache-2 @@ -23,7 +23,7 @@ readonly SCRIPT_VERSION='SCRIPT_VERSION_REPLACE' # definitions -CURL_DOWNLOAD_RETRY_COUNT=5 +## DGM CURL_DOWNLOAD_RETRY_COUNT=5 ## Repository locations and naming readonly default_salt_url_version="latest" @@ -39,7 +39,8 @@ readonly salt_name="salt" base_url="" # Broadcom infrastructure -bd_3006_base_url="https://packages.broadcom.com/artifactory/saltproject-generic" +bd_3006_base_url="https://packages.broadcom.com/artifactory/saltproject-generic/onedir" +bd_3006_chksum_base_url="https://packages.broadcom.com/artifactory/api/storage/saltproject-generic/onedir" # Salt file and directory locations @@ -122,8 +123,8 @@ readonly onedir_post_3005_location="${salt_dir}/salt-minion" readonly onedir_pre_3006_location="${salt_dir}/run/run" declare -a list_of_onedir_locations_check -## DGM TBD list_of_onedir_locations_check[0]="${onedir_pre_3006_location}" -## DGM TBD list_of_onedir_locations_check[1]="${onedir_post_3005_location}" +list_of_onedir_locations_check[0]="${onedir_pre_3006_location}" +list_of_onedir_locations_check[1]="${onedir_post_3005_location}" ## VMware file and directory locations readonly vmtools_base_dir_etc="/etc/vmware-tools" @@ -227,6 +228,7 @@ _log() { "${log_dir}/vmware-${SCRIPTNAME}-${LOG_ACTION}-${logdate}.log" } +# shellcheck disable=SC2329 _display() { if [[ ${VERBOSE_FLAG} -eq 1 ]]; then echo "$1"; fi _log "$*" @@ -266,6 +268,7 @@ _debug_log() { fi } +# shellcheck disable=SC2329 _yesno() { read -r -p "Continue (y/n)?" choice case "$choice" in @@ -334,6 +337,7 @@ esac # Results: # Exits with hard-coded value 130 # +# shellcheck disable=SC2329 _cleanup_int() { rm -rf "$WORK_DIR" @@ -347,6 +351,7 @@ _cleanup_int() { # # Cleanups any running process and areas on exit # +# shellcheck disable=SC2329 _cleanup_exit() { rm -rf "$WORK_DIR" _debug_log "$0:${FUNCNAME[0]} Deleted temp working directory $WORK_DIR" @@ -420,6 +425,8 @@ _set_log_level() { # for example: currently major version 3006 implies 3006.9 # the latest version of Salt 3006.x # +# if an unsupported version is input, for example: 3004.2, it will default to installing the latest version +# # Input: # directory contains directory list of current available Salt versions, 3006.x - 3007.1 # @@ -427,33 +434,59 @@ _set_log_level() { # Returns with exit code # _get_desired_salt_version_fn() { + # DGM debug output + set -x + set -v if [[ "$#" -ne 1 ]]; then _error_log "$0:${FUNCNAME[0]} error expected one parameter "\ "specifying the location for directories containing versions Salt" fi - _info_log "$0:${FUNCNAME[0]} processing getting desired Salt version for "\ - "salt-minion to install" + _info_log "$0:${FUNCNAME[0]} processing getting desired Salt version '$salt_url_version' for "\ + "salt-minion to install, input directory $1" generic_versions_tmpdir="$1" curr_pwd=$(pwd) cd ${generic_versions_tmpdir} || return 1 + # something werid is happening with tail, that does not fail in test programs getting failures inside tail hence use bash loop if [ "$salt_url_version" = "latest" ]; then # shellcheck disable=SC2010,SC2012 - _GENERIC_PKG_VERSION=$(ls ./ | sort -V -u | tail -n 1) + ## ## _GENERIC_PKG_VERSION=$(ls ./. | grep -v 'index.html' | sort -V -u | tail -n 1) + test_dir=$(ls ./. | grep -v 'index.html' | sort -V -u) + for idx in $test_dir + do + _GENERIC_PKG_VERSION="$idx" + done + _debug_log "$0:${FUNCNAME[0]} latest found version '${_GENERIC_PKG_VERSION}'" + elif [ "$(echo "$salt_url_version" | grep -E '^(3006|3007)$')" != "" ]; then # want major latest version of Salt # shellcheck disable=SC2010,SC2012 - _GENERIC_PKG_VERSION=$(ls ./ | sort -V -u | grep -E "$salt_url_version" | tail -n 1) + ## _GENERIC_PKG_VERSION=$(ls ./. | grep -v 'index.html' | sort -V -u | grep -E "$salt_url_version" | tail -n 1) + test_dir=$(ls ./. | grep -v 'index.html' | sort -V -u | grep -E "$salt_url_version") + for idx in $test_dir + do + _GENERIC_PKG_VERSION="$idx" + done + _debug_log "$0:${FUNCNAME[0]} input $salt_url_version found version '${_GENERIC_PKG_VERSION}'" + elif [ "$(echo "$salt_url_version" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then # Minor version Salt, want specific minor version + # if old style VMTools version 3004.2-1 is used, defaults to else and install latest _GENERIC_PKG_VERSION="$salt_url_version" else # default to latest version Salt # shellcheck disable=SC2010,SC2012 - _GENERIC_PKG_VERSION=$(ls ./ | sort -V -u | tail -n 1) + ## _GENERIC_PKG_VERSION=$(ls ./. | grep -v 'index.html' | sort -V -u | tail -n 1) + test_dir=$(ls ./. | grep -v 'index.html' | sort -V -u) + for idx in $test_dir + do + _GENERIC_PKG_VERSION="$idx" + done + _debug_log "$0:${FUNCNAME[0]} default found version '${_GENERIC_PKG_VERSION}'" + fi cd ${curr_pwd} || return 1 @@ -867,48 +900,48 @@ _fetch_vmtools_salt_minion_conf() { } -# -# _curl_download -# -# Retrieve file from specified url to specific file -# -# Results: -# Exits with 0 or error code -# - -_curl_download() { - local file_name="$1" - local file_url="$2" - local download_retry_failed=1 # assume issues - local _retn=0 - - _info_log "$0:${FUNCNAME[0]} attempting download of file '${file_name}'" - - for ((i=0; i> ~/.netrc -## id -## ls -alh svtminion.sh -## date -## sudo -u root yum makecache -## sudo -u root ./svtminion.sh --depend || { _retn=$?; if [[ ${_retn} -eq 126 ]]; then echo "test correct"; else echo "test failed, should be missing at least the vmtoolsd dependency, returned '${_retn}'"; exit 1; fi; } -## ls -alh /var/log/vmware-svtminion.sh-depend-* -## sudo -u root yum -y install open-vm-tools -## sudo -u root yum -y install curl -## sudo -u root yum -y install wget -## sudo -u root ./svtminion.sh --depend --loglevel info || { _retn=$?; echo "test failed, there should be no missing dependencies, returned '${_retn}'"; } -## ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l -## if [[ 2 -eq $(ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l) ]]; then echo "test correct"; else "test failed, should be 2 depend log files"; exit 1; fi -## ps -ef | grep svtminion -## sudo -u root pgrep -f "svtminion.sh" -## sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; } -## ls -alh /var/log/vmware-svtminion.sh-status-* -## sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## myhost=$(hostname) -## myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g") -## if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi -## ls -alh /opt/saltstack/salt/salt-minion -## ls -alh /usr/bin/salt-call -## ls -alh /usr/bin/salt-minion -## getent group salt | grep -w salt -## cat /etc/passwd | grep -w salt -## sudo -u root /usr/bin/salt-call --local test.versions -## sudo -u root /usr/bin/salt-call --local grains.items -## sudo -u root /usr/bin/salt-call --local cmd.run "ls -al /" -## sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --clear myminion -## cat /etc/salt/minion | grep 'id:\ myminion' 1>/dev/null -## sudo -u root ./svtminion.sh --clear -## cat /etc/salt/minion | grep '# id:\ myminion' 1>/dev/null -## cat /etc/salt/minion | grep 'id:\ myminion_' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## list_dirs_to_chk_removed="/opt/saltstack /etc/salt /var/run/salt /var/cache/salt /var/log/salt" -## for idx in ${list_dirs_to_chk_removed}; do if [[ -d "${idx}" ]]; then echo "directory ${idx} is left after a remove"; exit 1; fi; done -## list_files_to_chk_removed="/usr/bin/salt-call /usr/bin/salt-minion /usr/lib/systemd/system/salt-minion.service /etc/systemd/system/salt-minion.service" -## for idx in ${list_files_to_chk_removed}; do if [[ -f "${idx}" ]]; then echo "file ${idx} is left after a remove"; exit 1; fi; done -## sudo -u root ./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; } -## sudo -u root ./svtminion.sh --version --loglevel debug -## ls -alh /var/log/vmware-svtminion.sh-default-* -## sudo -u root ./svtminion.sh --minionversion "3004.2-1" --install master=192.168.0.6 --loglevel debug -## ls -alh /opt/saltstack/salt/run/ -## cat /etc/salt/minion | grep 'master:\ 192.168.0.6' 1>/dev/null -## myhost=$(hostname) -## myfqdn=$(sudo -u root /usr/bin/salt-call --local grains.get fqdn | sed "s/'//g") -## if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## ls -l /var/log/vmware-svtminion.sh-status-* -## ls -l /var/log/vmware-svtminion.sh-status-* | wc -l -## if [[ 5 -eq $(ls -l /var/log/vmware-svtminion.sh-status-* | wc -l) ]]; then echo "test correct"; else "test failed, should be only 5 status log files"; exit 1; fi -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## -## # DGM TBD no more rpeo.json - test source installs with repo.json -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --source file:/${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m "3003.3-1" # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## # test source installs with repo.json post_3005 # DGM FIX -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006 # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3006.6 # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug --minionversion 3007 # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt_rc/salt/py3/onedir # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## # test stop and start -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://staging.repo.saltproject.io/salt/py3/onedir # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sleep 1 -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ps -ef | grep salt -## sudo -u root systemctl is-active salt-minion -## sudo -u root ./svtminion.sh --stop --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 107 ]]; then echo "test correct"; else echo "test failed, salt-minion should be stopped, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ps -ef | grep salt -## systemctl is-active salt-minion || { echo "test correct"; } -## sudo -u root ps -ef | grep salt -## sudo -u root ./svtminion.sh --start --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ps -ef | grep salt -## systemctl is-active salt-minion || { echo "test failed, salt-minion should be running"; exit 1; } -## # test reconfig -## cat /etc/salt/minion -## sudo -u root ./svtminion.sh --reconfig master=192.168.0.7 --loglevel debug -## sleep 3 -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; } -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.7' 1>/dev/null -## sudo -u root ps -ef | grep salt -## systemctl is-active salt-minion -## # test 3006-3007 and upgrade +# Testing assumes RedHat family + +oldpwd=$(pwd) +mkdir -p /root/ || true +## echo "machine gitlab.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >> ~/.netrc +id +date +yum makecache +ls -alh +sleep 1 +ls -alh linux/svtminion.sh +sleep 1 +cd linux +./svtminion.sh --depend || { _retn=$?; if [[ ${_retn} -eq 126 ]]; then echo "test correct"; else echo "test failed, should be missing at least the vmtoolsd dependency, returned '${_retn}'"; exit 1; fi; } +ls -alh /var/log/vmware-svtminion.sh-depend-* +yum -y install open-vm-tools +yum -y install --allowerasing curl +yum -y install wget +yum -y install procps-ng +./svtminion.sh --depend --loglevel info || { _retn=$?; echo "test failed, there should be no missing dependencies, returned '${_retn}'"; } +ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l +if [[ 2 -eq $(ls -l /var/log/vmware-svtminion.sh-depend-* | wc -l) ]]; then echo "test correct"; else "test failed, should be 2 depend log files"; exit 1; fi +ps -ef | grep svtminion +pgrep -f "svtminion.sh" +./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; } +ls -alh /var/log/vmware-svtminion.sh-status-* +./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; } +./svtminion.sh --install master=192.168.0.5 --loglevel debug +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +myhost=$(hostname) +myfqdn=$(/usr/bin/salt-call --local grains.get fqdn | sed "s/'//g") +if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi +ls -alh /opt/saltstack/salt/salt-minion +ls -alh /usr/bin/salt-call +ls -alh /usr/bin/salt-minion +getent group salt | grep -w salt +cat /etc/passwd | grep -w salt +/usr/bin/salt-call --local test.versions +/usr/bin/salt-call --local grains.items +/usr/bin/salt-call --local cmd.run "ls -al /" +./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --clear myminion +cat /etc/salt/minion | grep 'id:\ myminion' 1>/dev/null +./svtminion.sh --clear +cat /etc/salt/minion | grep '# id:\ myminion' 1>/dev/null +cat /etc/salt/minion | grep 'id:\ myminion_' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +list_dirs_to_chk_removed="/opt/saltstack /etc/salt /var/run/salt /var/cache/salt /var/log/salt" +for idx in ${list_dirs_to_chk_removed}; do if [[ -d "${idx}" ]]; then echo "directory ${idx} is left after a remove"; exit 1; fi; done +list_files_to_chk_removed="/usr/bin/salt-call /usr/bin/salt-minion /usr/lib/systemd/system/salt-minion.service /etc/systemd/system/salt-minion.service" +for idx in ${list_files_to_chk_removed}; do if [[ -f "${idx}" ]]; then echo "file ${idx} is left after a remove"; exit 1; fi; done +./svtminion.sh --status || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should not be installed, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --status && { echo "test failed- expecting 102 exit code, salt-minion should not be installed"; exit 1; } +./svtminion.sh --version --loglevel debug +ls -alh /var/log/vmware-svtminion.sh-default-* +# if version not found, defaults to latest +./svtminion.sh --minionversion "3004.2-1" --install master=192.168.0.6 --loglevel debug +ls -alh /opt/saltstack/salt/run/ +cat /etc/salt/minion | grep 'master:\ 192.168.0.6' 1>/dev/null +myhost=$(hostname) +myfqdn=$(/usr/bin/salt-call --local grains.get fqdn | sed "s/'//g") +if [[ "${myhost}" = "${myfqdn}" ]]; then "echo test correct" else echo "test failed, FQDN '${myfqdn}' should have match hostname '${myhost}'"; exit 1; fi +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +ls -l /var/log/vmware-svtminion.sh-status-* +ls -l /var/log/vmware-svtminion.sh-status-* | wc -l +if [[ 5 -eq $(ls -l /var/log/vmware-svtminion.sh-status-* | wc -l) ]]; then echo "test correct"; else "test failed, should be only 5 status log files"; exit 1; fi +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } + +# DGM TBD no more rpeo.json - test source installs with repo.json +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source file:/${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m "3003.3-1" # DGM FIX +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir # DGM FIX +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source ${oldpwd}/tests/testarea -m "3006.8" --install master=192.168.0.5 --loglevel debug +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 102 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 3006 # DGM FIX +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 3006.9 # DGM FIX +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 3007 # DGM FIX +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +## wait for RC with 3008 ## ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sleep 1 -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 id="tup" --loglevel debug --minionversion 3006 # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null -## sudo -u root ps -ef | grep salt -## systemctl is-active salt-minion -## if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3006 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --upgrade --install --loglevel debug --minionversion 3007 # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null -## sudo -u root ps -ef | grep salt -## systemctl is-active salt-minion -## if [[ $(sudo -u root /usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3007 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi -## # test source installs without repo.json -## cd ${oldpwd}/tests/testarea -## mv repo.json repo.json_hold # DGM FIX -## cd ${oldpwd} -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3004-1 # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://repo.saltproject.io/salt/vmware-tools-onedir # DGM FIX -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## cd ${oldpwd}/tests/testarea -## mv repo.json_hold repo.json -## cd ${oldpwd} -## # test source installs without repo.json for post_3005 -## cd ${oldpwd}/tests/testarea/test_onedir # DGM FIX -## mv repo.json repo.json_hold # DGM FIX -## cd ${oldpwd} -## sudo -u root ./svtminion.sh --source ${oldpwd}/tests/testarea/test_onedir --install master=192.168.0.5 --loglevel debug # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## # restore normal test source installs with 2 repo.json for post_3005 -## cd ${oldpwd}/tests/testarea/test_onedir # DGM FIX -## mv repo.json_hold repo.json # DGM FIX -## cd ${oldpwd} -## sudo -u root bash -x ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea/test_onedir -m 3007.1 # DGM FIX -## cat /etc/salt/minion -## cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null -## sudo -u root ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } -## # test with classic package installed -## sudo -u root rpm --import https://repo.saltproject.io/py3/redhat/8/x86_64/3005/SALTSTACK-GPG-KEY.pub # DGM FIX -## sudo -u root curl -fsSL https://repo.saltproject.io/py3/redhat/8/x86_64/3005.repo | sudo -u root tee /etc/yum.repos.d/salt.repo # DGM FIX -## sudo -u root yum makecache -## sudo -u root yum -y install salt-minion -## sudo -u root ./svtminion.sh --install master=192.168.0.5 --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, classic salt-minion should be installed and external install detected, returned '${_retn}'"; exit 1; fi; } -## sudo -u root ./svtminion.sh --remove || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed and script remove not valid, returned '${_retn}'"; exit 1; fi; } +## ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/saltproject-generic/onedir +## ./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +## sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +# test stop and start +./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/saltproject-generic/onedir +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +sleep 1 +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +ps -ef | grep salt +systemctl is-active salt-minion +./svtminion.sh --stop --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 107 ]]; then echo "test correct"; else echo "test failed, salt-minion should be stopped, returned '${_retn}'"; exit 1; fi; } +ps -ef | grep salt +systemctl is-active salt-minion || { echo "test correct"; } +ps -ef | grep salt +./svtminion.sh --start --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; } +ps -ef | grep salt +systemctl is-active salt-minion || { echo "test failed, salt-minion should be running"; exit 1; } +# test reconfig +cat /etc/salt/minion +./svtminion.sh --reconfig master=192.168.0.7 --loglevel debug +sleep 3 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be running, returned '${_retn}'"; exit 1; fi; } +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.7' 1>/dev/null +ps -ef | grep salt +systemctl is-active salt-minion +# test 3006-3007 and upgrade +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +sleep 1 +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 id="tup" --loglevel debug --minionversion 3006 # DGM FIX +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null +ps -ef | grep salt +systemctl is-active salt-minion +if [[ $(/usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3006 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi +./svtminion.sh --source ${oldpwd}/tests/testarea --upgrade --install --loglevel debug --minionversion 3007 # DGM FIX +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +cat /etc/salt/minion | grep 'id:\ tup' 1>/dev/null +ps -ef | grep salt +systemctl is-active salt-minion +if [[ $(/usr/bin/salt-call --local test.version --out=pprint | awk '{print $2}' | cut -d "'" -f 2 | awk -F "." '{print $1}') -eq 3007 ]]; then echo "test correct"; else echo "test failed, wrong major version for salt-minion"; exit 1; fi +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug # DGM FIX +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3007 +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/saltproject-generic/onedir +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +bash -x ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3007.1 # DGM FIX +cat /etc/salt/minion +cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null +./svtminion.sh --status --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 100 ]]; then echo "test correct"; else echo "test failed, salt-minion should be installed, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; } +# test with classic package installed +rpm --import https://repo.saltproject.io/py3/redhat/8/x86_64/3005/SALTSTACK-GPG-KEY.pub # DGM FIX +curl -fsSL https://repo.saltproject.io/py3/redhat/8/x86_64/3005.repo | tee /etc/yum.repos.d/salt.repo # DGM FIX +yum makecache +yum -y install salt-minion +./svtminion.sh --install master=192.168.0.5 --loglevel debug || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --status --loglevel info || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, classic salt-minion should be installed and external install detected, returned '${_retn}'"; exit 1; fi; } +./svtminion.sh --remove || { _retn=$?; if [[ ${_retn} -eq 106 ]]; then echo "test correct"; else echo "test failed, should fail since be standard salt-minion installed and script remove not valid, returned '${_retn}'"; exit 1; fi; }