Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# salt-vm-tools

The VMTools salt integration script installs, removes, or checks the status of a Salt minion
(`salt-minion`) in a VMware controlled Virtual Machine environment.
The VMTools salt integration script installs, removes, or checks the status of
a Salt minion (`salt-minion`) in a VMware controlled Virtual Machine environment.

This script operates as a BASH script in Linux environments and a PowerShell
script in Windows environments.

The Salt minion is a [Tiamat](https://gitlab.com/saltstack/pop/tiamat) based
Python 3 Salt minion leveraging [PyInstaller's](https://www.pyinstaller.org/)
onedir option internally. The Salt minion is fully self-contained and requires
no additional dependencies.
The Salt minion is a Onedir architecture based Python 3 Salt minion leveraging
relenv (https://github.com/saltstack/relenv) onedir option internally.
The Salt minion is fully self-contained and requires no additional dependencies.

The script can install, remove, and check the status of an installed Salt minion
either using a direct command line option or via VMware's use of Guest Variables,
Expand Down
249 changes: 37 additions & 212 deletions linux/svtminion.sh

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions tests/classic/3005.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[salt-repo]
name=Salt repo for RHEL/CentOS 9 PY3
## baseurl=https://repo.saltproject.io/salt/py3/redhat/9/x86_64/3005
## baseurl=file:///testarea/classic
skip_if_unavailable=True
priority=10
enabled=1
enabled_metadata=1
gpgcheck=1
## gpgkey=https://repo.saltproject.io/salt/py3/redhat/9/x86_64/3005/SALTSTACK-GPG-KEY2.pub
## gpgkey=file:///testarea/classic/SALTSTACK-GPG-KEY2.pub
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
55 changes: 55 additions & 0 deletions tests/classic/repodata/repomd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<revision>1706636449</revision>
<data type="primary">
<checksum type="sha256">d3a079a4c70a032e11f10888785f20c3bd8f45ecd01729e6310ca8782e9df025</checksum>
<open-checksum type="sha256">71230d9804cc906d363a02d811d8f3a1dba0defdacbcb4a9cc3aaadafd0c646d</open-checksum>
<location href="repodata/d3a079a4c70a032e11f10888785f20c3bd8f45ecd01729e6310ca8782e9df025-primary.xml.gz"/>
<timestamp>1706636448</timestamp>
<size>2550</size>
<open-size>15539</open-size>
</data>
<data type="filelists">
<checksum type="sha256">f1dea79a80a01020329ae48e70174a3739b5d83e83412350761dd975582aa8e7</checksum>
<open-checksum type="sha256">7bb95e492d87215848b8c36192dfb8c78824cf0b37d456fc635f4a8a4965fc0e</open-checksum>
<location href="repodata/f1dea79a80a01020329ae48e70174a3739b5d83e83412350761dd975582aa8e7-filelists.xml.gz"/>
<timestamp>1706636448</timestamp>
<size>42252</size>
<open-size>498371</open-size>
</data>
<data type="other">
<checksum type="sha256">8683c1116fb5581b1243a6b03e9fddc2946c777d4c609ff202de0e5b43c4b283</checksum>
<open-checksum type="sha256">b329b95b139221d76c50e7fa6cbd40f1475ddbe8887302fc92b8f163117441c8</open-checksum>
<location href="repodata/8683c1116fb5581b1243a6b03e9fddc2946c777d4c609ff202de0e5b43c4b283-other.xml.gz"/>
<timestamp>1706636448</timestamp>
<size>772</size>
<open-size>4649</open-size>
</data>
<data type="primary_db">
<checksum type="sha256">357f3ecd84cb206c4dcda6cf750c84b503097cb065a8996f6d7094821e1c42e4</checksum>
<open-checksum type="sha256">9fe73b8a2f3b8bc685073acc4749544aabb18380af8d5eab90b942db3e93e13b</open-checksum>
<location href="repodata/357f3ecd84cb206c4dcda6cf750c84b503097cb065a8996f6d7094821e1c42e4-primary.sqlite.bz2"/>
<timestamp>1706636448</timestamp>
<size>6019</size>
<open-size>114688</open-size>
<database_version>10</database_version>
</data>
<data type="filelists_db">
<checksum type="sha256">732c3667da5d18b4d7a60c65d7a1ac3e21de6416d54fcc42a1fd137ff6baad37</checksum>
<open-checksum type="sha256">a33dfdfa2cfd6de5f316efda87a46055fa65d4ca4a077f9dbe2f7d01edded9e5</open-checksum>
<location href="repodata/732c3667da5d18b4d7a60c65d7a1ac3e21de6416d54fcc42a1fd137ff6baad37-filelists.sqlite.bz2"/>
<timestamp>1706636449</timestamp>
<size>40445</size>
<open-size>204800</open-size>
<database_version>10</database_version>
</data>
<data type="other_db">
<checksum type="sha256">7e627ecb05c689fa71a37710be55c5517549d1c113f567b1db12cdf359a758c6</checksum>
<open-checksum type="sha256">3b3096b8d3218e13f0eff1d01b62893bf389adb1590f67142099d0d9a3159a3c</open-checksum>
<location href="repodata/7e627ecb05c689fa71a37710be55c5517549d1c113f567b1db12cdf359a758c6-other.sqlite.bz2"/>
<timestamp>1706636448</timestamp>
<size>1661</size>
<open-size>24576</open-size>
<database_version>10</database_version>
</data>
</repomd>
Binary file added tests/classic/salt-3005.5-2.el9.x86_64.rpm
Binary file not shown.
Binary file added tests/classic/salt-minion-3005.5-2.el9.x86_64.rpm
Binary file not shown.
41 changes: 20 additions & 21 deletions tests/linux/test-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ 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
Expand All @@ -117,13 +115,7 @@ 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 --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m "3003.3-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
cat /etc/salt/minion
Expand All @@ -137,31 +129,31 @@ 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
./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 3006
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 --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 3006.9
./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 --source ${oldpwd}/tests/testarea --install master=192.168.0.5 --loglevel debug --minionversion 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; }
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}'"; }
## ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/saltproject-generic/onedir
## ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/artifactory/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 --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/artifactory/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
Expand All @@ -187,21 +179,21 @@ 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
./svtminion.sh --source ${oldpwd}/tests/testarea --install master=192.168.0.5 id="tup" --loglevel debug --minionversion 3006
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
./svtminion.sh --source ${oldpwd}/tests/testarea --upgrade --install --loglevel debug --minionversion 3007
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
./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 --remove || { _retn=$?; echo "test failed, did not uninstall the salt-minion, returned '${_retn}'"; }
Expand All @@ -210,7 +202,7 @@ cat /etc/salt/minion | grep 'master:\ 192.168.0.5' 1>/dev/null
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 --install master=192.168.0.5 --loglevel debug --source https://packages.broadcom.com/artifactory/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
Expand All @@ -220,16 +212,23 @@ 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
bash -x ./svtminion.sh --install master=192.168.0.5 --loglevel debug --source file:/${oldpwd}/tests/testarea -m 3007.1
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
## 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
# Use 3005 Redhat 9 for Rocky 9 container
rpm --import ${oldpwd}/tests/classic/SALTSTACK-GPG-KEY2.pub
cp -a ${oldpwd}/tests/classic/3005.repo /etc/yum.repos.d/salt.repo
echo "baseurl=file:///${oldpwd}/testarea/classic" >> /etc/yum.repos.d/salt.repo
echo "gpgkey=file:///${oldpwd}/testarea/classic/SALTSTACK-GPG-KEY2.pub" >> /etc/yum.repos.d/salt.repo
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; }
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading