Added support with -W for installing salt-api

This commit is contained in:
David Murphy 2024-07-23 13:51:53 -06:00
parent 4f5a393916
commit 3e207e087f
No known key found for this signature in database
GPG key ID: 9D7724F37A7424D8
2 changed files with 60 additions and 5 deletions

View file

@ -119,6 +119,7 @@ To view the latest options and descriptions for ``salt-bootstrap``, use ``-h`` a
-L Also install salt-cloud and required python-libcloud package -L Also install salt-cloud and required python-libcloud package
-M Also install salt-master -M Also install salt-master
-S Also install salt-syndic -S Also install salt-syndic
-W Also install salt-api
-N Do not install salt-minion -N Do not install salt-minion
-X Do not start daemons after installation -X Do not start daemons after installation
-d Disables checking if Salt services are enabled to start on system boot. -d Disables checking if Salt services are enabled to start on system boot.

View file

@ -26,7 +26,7 @@
#====================================================================================================================== #======================================================================================================================
set -o nounset # Treat unset variables as an error set -o nounset # Treat unset variables as an error
__ScriptVersion="2024.07.18" __ScriptVersion="2024.07.23"
__ScriptName="bootstrap-salt.sh" __ScriptName="bootstrap-salt.sh"
__ScriptFullName="$0" __ScriptFullName="$0"
@ -228,6 +228,7 @@ _TEMP_KEYS_DIR="null"
_SLEEP="${__DEFAULT_SLEEP}" _SLEEP="${__DEFAULT_SLEEP}"
_INSTALL_MASTER=$BS_FALSE _INSTALL_MASTER=$BS_FALSE
_INSTALL_SYNDIC=$BS_FALSE _INSTALL_SYNDIC=$BS_FALSE
_INSTALL_SALT_API=$BS_FALSE
_INSTALL_MINION=$BS_TRUE _INSTALL_MINION=$BS_TRUE
_INSTALL_CLOUD=$BS_FALSE _INSTALL_CLOUD=$BS_FALSE
_VIRTUALENV_DIR=${BS_VIRTUALENV_DIR:-"null"} _VIRTUALENV_DIR=${BS_VIRTUALENV_DIR:-"null"}
@ -339,7 +340,7 @@ __usage() {
step. step.
-c Temporary configuration directory -c Temporary configuration directory
-C Only run the configuration function. Implies -F (forced overwrite). -C Only run the configuration function. Implies -F (forced overwrite).
To overwrite Master or Syndic configs, -M or -S, respectively, must To overwrite Master, Syndic or Api configs, -M,-S or -W, respectively, must
also be specified. Salt installation will be ommitted, but some of the also be specified. Salt installation will be ommitted, but some of the
dependencies could be installed to write configuration with -j or -J. dependencies could be installed to write configuration with -j or -J.
-d Disables checking if Salt services are enabled to start on system boot. -d Disables checking if Salt services are enabled to start on system boot.
@ -397,6 +398,7 @@ __usage() {
-s Sleep time used when waiting for daemons to start, restart and when -s Sleep time used when waiting for daemons to start, restart and when
checking for the services running. Default: ${__DEFAULT_SLEEP} checking for the services running. Default: ${__DEFAULT_SLEEP}
-S Also install salt-syndic -S Also install salt-syndic
-W Also install salt-api
-r Disable all repository configuration performed by this script. This -r Disable all repository configuration performed by this script. This
option assumes all necessary repository configuration is already present option assumes all necessary repository configuration is already present
on the system. on the system.
@ -411,7 +413,7 @@ __usage() {
EOT EOT
} # ---------- end of function __usage ---------- } # ---------- end of function __usage ----------
while getopts ':hvnDc:g:Gx:k:s:MSNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:aqQ' opt while getopts ':hvnDc:g:Gx:k:s:MSWNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:aqQ' opt
do do
case "${opt}" in case "${opt}" in
@ -431,6 +433,7 @@ do
s ) _SLEEP=$OPTARG ;; s ) _SLEEP=$OPTARG ;;
M ) _INSTALL_MASTER=$BS_TRUE ;; M ) _INSTALL_MASTER=$BS_TRUE ;;
S ) _INSTALL_SYNDIC=$BS_TRUE ;; S ) _INSTALL_SYNDIC=$BS_TRUE ;;
W ) _INSTALL_SALT_API=$BS_TRUE ;;
N ) _INSTALL_MINION=$BS_FALSE ;; N ) _INSTALL_MINION=$BS_FALSE ;;
X ) _START_DAEMONS=$BS_FALSE ;; X ) _START_DAEMONS=$BS_FALSE ;;
C ) _CONFIG_ONLY=$BS_TRUE ;; C ) _CONFIG_ONLY=$BS_TRUE ;;
@ -718,7 +721,7 @@ if [ "$($whoami)" != "root" ]; then
fi fi
# Check that we're actually installing one of minion/master/syndic # Check that we're actually installing one of minion/master/syndic
if [ "$_INSTALL_MINION" -eq $BS_FALSE ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then if [ "$_INSTALL_MINION" -eq $BS_FALSE ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && [ "$_INSTALL_SALT_API" -eq $BS_FALSE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then
echowarn "Nothing to install or configure" echowarn "Nothing to install or configure"
exit 1 exit 1
fi fi
@ -1767,6 +1770,14 @@ if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then
fi fi
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then
echoinfo "Installing salt api"
else
echoinfo "Configuring salt api"
fi
fi
if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then
echoinfo "Installing salt-cloud and required python3-libcloud package" echoinfo "Installing salt-cloud and required python3-libcloud package"
fi fi
@ -3123,6 +3134,10 @@ install_ubuntu_stable() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__apt_get_install_noinput ${__PACKAGES} || return 1 __apt_get_install_noinput ${__PACKAGES} || return 1
@ -3174,6 +3189,10 @@ install_ubuntu_onedir() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__apt_get_install_noinput ${__PACKAGES} || return 1 __apt_get_install_noinput ${__PACKAGES} || return 1
@ -3527,6 +3546,10 @@ install_debian_stable() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__apt_get_install_noinput ${__PACKAGES} || return 1 __apt_get_install_noinput ${__PACKAGES} || return 1
@ -3598,6 +3621,10 @@ install_debian_onedir() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__apt_get_install_noinput ${__PACKAGES} || return 1 __apt_get_install_noinput ${__PACKAGES} || return 1
@ -3948,6 +3975,10 @@ install_fedora_onedir() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__yum_install_noinput ${__PACKAGES} || return 1 __yum_install_noinput ${__PACKAGES} || return 1
@ -4093,6 +4124,10 @@ install_centos_stable() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__yum_install_noinput ${__PACKAGES} || return 1 __yum_install_noinput ${__PACKAGES} || return 1
@ -4289,6 +4324,10 @@ install_centos_onedir() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__yum_install_noinput ${__PACKAGES} || return 1 __yum_install_noinput ${__PACKAGES} || return 1
@ -5144,6 +5183,10 @@ install_alpine_linux_stable() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
apk -U add "${__PACKAGES}" || return 1 apk -U add "${__PACKAGES}" || return 1
return 0 return 0
@ -6150,6 +6193,10 @@ install_photon_onedir() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__tdnf_install_noinput ${__PACKAGES} || return 1 __tdnf_install_noinput ${__PACKAGES} || return 1
@ -6346,6 +6393,10 @@ install_opensuse_stable() {
__PACKAGES="${__PACKAGES} salt-syndic" __PACKAGES="${__PACKAGES} salt-syndic"
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-api"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__zypper_install $__PACKAGES || return 1 __zypper_install $__PACKAGES || return 1
@ -7294,8 +7345,11 @@ config_salt() {
if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then
OVERWRITE_MASTER_CONFIGS=$BS_TRUE OVERWRITE_MASTER_CONFIGS=$BS_TRUE
fi fi
if [ "$_INSTALL_SALT_API" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then
OVERWRITE_MASTER_CONFIGS=$BS_TRUE
fi
if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] || [ "$OVERWRITE_MASTER_CONFIGS" -eq $BS_TRUE ] || [ "$_CUSTOM_MASTER_CONFIG" != "null" ]; then if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] || [ "$_INSTALL_SALT_API" -eq $BS_TRUE ] || [ "$OVERWRITE_MASTER_CONFIGS" -eq $BS_TRUE ] || [ "$_CUSTOM_MASTER_CONFIG" != "null" ]; then
# Create the PKI directory # Create the PKI directory
[ -d "$_PKI_DIR/master" ] || (mkdir -p "$_PKI_DIR/master" && chmod 700 "$_PKI_DIR/master") || return 1 [ -d "$_PKI_DIR/master" ] || (mkdir -p "$_PKI_DIR/master" && chmod 700 "$_PKI_DIR/master") || return 1