Last active
January 31, 2019 21:14
-
-
Save WillSams/701fe7e2e76f6dff3504ab2cd6c1cdd4 to your computer and use it in GitHub Desktop.
Install and Configure Salt Minion on Debian-based System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o nounset # unset variables are errors | |
SCRIPTVERSION="2019.01.25-Debian" | |
SCRIPTNAME="install-salt-minion.sh" | |
SCRIPTFULLNAME="$0" | |
SALTMASTER='192.168.56.101' #IP of Salt-master | |
echoerror() { printf "\033[1;31m * ERROR\033[0m: %s\\n" "$@" 1>&2; } | |
usage() { | |
cat << EOT | |
Usage : ${SCRIPTNAME} [options] | |
Options: | |
-h Display this message | |
-v Display script version | |
-m IP address server in salt-master role. Default is 192.168.56.101. | |
EOT | |
} # ---------- end of function usage ---------- | |
while getopts ':hvm:' opt | |
do | |
case "${opt}" in | |
h ) usage; exit 0 ;; | |
v ) echo "$0 -- Version $SCRIPTVERSION"; exit 0 ;; | |
m ) SALTMASTER=$OPTARG ;; | |
\?) echo | |
echoerror "Option does not exist : $OPTARG" | |
usage | |
exit 1 | |
;; | |
esac # --- end of case --- | |
done | |
shift $((OPTIND-1)) | |
if [ -f /etc/salt/minion ]; then | |
echo "Salt (minion) is already installed on $HOSTNAME." | |
else | |
echo "************************ SALT-MINION INSTALL **************************" | |
echo "Installing SALT-MINION" | |
echo "You may be prompted for root credentials to complete the install." | |
echo "******************************************************************" | |
sudo bash -c "add-apt-repository universe && apt update -y && apt upgrade -y" | |
sudo bash -c "apt install salt-minion -y" | |
sudo bash -c "echo -e 'master: $SALTMASTER' >> /etc/salt/minion" | |
sudo bash -c "echo '$SALTMASTER salt' >> /etc/hosts" | |
sudo bash -c "systemctl enable salt-minion.service && service salt-minion restart" | |
echo "$SCRIPTFULLNAME ($SCRIPTVERSION) complete." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment