Merge develop into stable for v2024.12.09 release

This commit is contained in:
Salt Project Packaging 2024-12-09 23:10:50 +00:00
commit 53fd020df7
5 changed files with 380 additions and 123 deletions

View file

@ -1,3 +1,12 @@
# v2024.12.09
## What's Changed
- Fix quickstart for Windows with new repo by @twangboy in https://github.com/saltstack/salt-bootstrap/pull/2065
- Utilize salt-project packages with SUSE by @dmurphy18 in https://github.com/saltstack/salt-bootstrap/pull/2066
**Full Changelog**: https://github.com/saltstack/salt-bootstrap/compare/v2024.11.29...v2024.12.09
# v2024.11.29 # v2024.11.29
## What's Changed ## What's Changed

View file

@ -37,6 +37,7 @@ sum** of the downloaded ``bootstrap-salt.sh`` file.
The SHA256 sum of the ``bootstrap-salt.sh`` file, per release, is: The SHA256 sum of the ``bootstrap-salt.sh`` file, per release, is:
- 2024.11.29: ``0ac87384dee051aceded69704485a5de0e4a308551a462b10c262111b57acff0``
- 2024.11.27: ``e972bd1ef01d09cd1d9294374ef974c9e3dd9a2aee37cf3859144585fd8bf1d0`` - 2024.11.27: ``e972bd1ef01d09cd1d9294374ef974c9e3dd9a2aee37cf3859144585fd8bf1d0``
- 2024.11.26: ``832c7a20b96e1df171d715323df9afff8a11aef42d15598c007f240bc89d723c`` - 2024.11.26: ``832c7a20b96e1df171d715323df9afff8a11aef42d15598c007f240bc89d723c``
- 2024.11.21: ``ddf624c3a94d721da3f7629402a6c7ecc9dd96d13c1ead2a626314e97cee982a`` - 2024.11.21: ``ddf624c3a94d721da3f7629402a6c7ecc9dd96d13c1ead2a626314e97cee982a``

View file

@ -108,7 +108,7 @@ if ($help) {
exit 0 exit 0
} }
$__ScriptVersion = "2024.11.29" $__ScriptVersion = "2024.12.09"
$ScriptName = $myInvocation.MyCommand.Name $ScriptName = $myInvocation.MyCommand.Name
# We'll check for the Version next, because it also has no requirements # We'll check for the Version next, because it also has no requirements

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.11.29" __ScriptVersion="2024.12.09"
__ScriptName="bootstrap-salt.sh" __ScriptName="bootstrap-salt.sh"
__ScriptFullName="$0" __ScriptFullName="$0"
@ -3053,8 +3053,9 @@ __install_saltstack_ubuntu_onedir_repository() {
echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001
echo "Pin: version $ONEDIR_REV" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $ONEDIR_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
fi fi
fi fi
@ -3506,8 +3507,10 @@ __install_saltstack_debian_repository() {
echo "Pin: version $STABLE_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $STABLE_REV.*" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$STABLE_REV_DOT"
echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001
echo "Pin: version $STABLE_REV" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $STABLE_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
fi fi
fi fi
@ -3549,8 +3552,9 @@ __install_saltstack_debian_onedir_repository() {
echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $ONEDIR_REV.*" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001 echo "Package: salt-*" > /etc/apt/preferences.d/salt-pin-1001
echo "Pin: version $ONEDIR_REV" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin: version $ONEDIR_REV_DOT" >> /etc/apt/preferences.d/salt-pin-1001
echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001 echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/salt-pin-1001
fi fi
fi fi
@ -3895,9 +3899,10 @@ __install_saltstack_fedora_onedir_repository() {
fi fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -4140,7 +4145,8 @@ install_fedora_onedir() {
MINOR_VER_STRG="" MINOR_VER_STRG=""
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# Minor version Salt, need to add specific minor version # Minor version Salt, need to add specific minor version
MINOR_VER_STRG="-$STABLE_REV" STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$STABLE_REV_DOT"
else else
MINOR_VER_STRG="" MINOR_VER_STRG=""
fi fi
@ -4223,9 +4229,10 @@ __install_saltstack_rhel_onedir_repository() {
fi fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -4297,7 +4304,8 @@ install_centos_stable() {
MINOR_VER_STRG="" MINOR_VER_STRG=""
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# Minor version Salt, need to add specific minor version # Minor version Salt, need to add specific minor version
MINOR_VER_STRG="-$STABLE_REV" STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$STABLE_REV_DOT"
else else
MINOR_VER_STRG="" MINOR_VER_STRG=""
fi fi
@ -4525,7 +4533,8 @@ install_centos_onedir() {
MINOR_VER_STRG="" MINOR_VER_STRG=""
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# Minor version Salt, need to add specific minor version # Minor version Salt, need to add specific minor version
MINOR_VER_STRG="-$ONEDIR_REV" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$ONEDIR_REV_DOT"
else else
MINOR_VER_STRG="" MINOR_VER_STRG=""
fi fi
@ -5657,9 +5666,10 @@ install_amazon_linux_ami_2_deps() {
fi fi
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${STABLE_REV}-lts]" > "${YUM_REPO_FILE}" STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
echo "[salt-repo-${STABLE_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "name=Salt Repo for Salt v${STABLE_REV} LTS" >> "${YUM_REPO_FILE}" echo "name=Salt Repo for Salt v${STABLE_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -5721,9 +5731,10 @@ install_amazon_linux_ami_2_onedir_deps() {
fi fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -5873,9 +5884,10 @@ install_amazon_linux_ami_2023_onedir_deps() {
fi fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -6286,8 +6298,9 @@ __install_saltstack_photon_onedir_repository() {
fi fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version # using minor version
echo "[salt-repo-${ONEDIR_REV}-lts]" > "${YUM_REPO_FILE}" ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "name=Salt Repo for Salt v${ONEDIR_REV} LTS" >> "${YUM_REPO_FILE}" echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}" echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}" echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}" echo "priority=10" >> "${YUM_REPO_FILE}"
@ -6582,7 +6595,8 @@ install_photon_onedir() {
MINOR_VER_STRG="-$_GENERIC_PKG_VERSION" MINOR_VER_STRG="-$_GENERIC_PKG_VERSION"
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# Minor version Salt, need to add specific minor version # Minor version Salt, need to add specific minor version
MINOR_VER_STRG="-$STABLE_REV" STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$STABLE_REV_DOT"
else else
# default to latest version Salt, config and repo already setup # default to latest version Salt, config and repo already setup
__get_packagesite_onedir_latest __get_packagesite_onedir_latest
@ -6632,38 +6646,85 @@ install_photon_onedir_post() {
# #
__ZYPPER_REQUIRES_REPLACE_FILES=-1 __ZYPPER_REQUIRES_REPLACE_FILES=-1
__set_suse_pkg_repo() {
# Set distro repo variable
if [ "${DISTRO_MAJOR_VERSION}" -gt 2015 ]; then
DISTRO_REPO="openSUSE_Tumbleweed"
elif [ "${DISTRO_MAJOR_VERSION}" -eq 15 ] && [ "${DISTRO_MINOR_VERSION}" -ge 4 ]; then
DISTRO_REPO="${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}"
elif [ "${DISTRO_MAJOR_VERSION}" -ge 42 ] || [ "${DISTRO_MAJOR_VERSION}" -eq 15 ]; then
DISTRO_REPO="openSUSE_Leap_${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}"
else
DISTRO_REPO="SLE_${DISTRO_MAJOR_VERSION}_SP${SUSE_PATCHLEVEL}"
fi
suse_pkg_url_base="https://download.opensuse.org/repositories/systemsmanagement:/saltstack"
suse_pkg_url_path="${DISTRO_REPO}/systemsmanagement:saltstack.repo"
SUSE_PKG_URL="$suse_pkg_url_base/$suse_pkg_url_path"
}
__check_and_refresh_suse_pkg_repo() { __check_and_refresh_suse_pkg_repo() {
# Check to see if systemsmanagement_saltstack exists # Check to see if systemsmanagement_saltstack exists
__zypper repos | grep -q systemsmanagement_saltstack __zypper repos | grep -q 'salt.repo'
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
# zypper does not yet know anything about systemsmanagement_saltstack # zypper does not yet know anything about salt.repo
__zypper addrepo --refresh "${SUSE_PKG_URL}" || return 1 # zypper does not support exclude similar to Photon, hence have to do following
ZYPPER_REPO_FILE="/etc/zypp/repos.d/salt.repo"
# shellcheck disable=SC2129
if [ "$ONEDIR_REV" != "latest" ]; then
# 3006.x is default, and latest for 3006.x branch
if [ "$(echo "$ONEDIR_REV" | grep -E '^(3006|3007)$')" != "" ]; then
# latest version for branch 3006 | 3007
REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1)
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
# Enable the Salt 3007 STS repo
echo "[salt-repo-3007-sts]" > "${ZYPPER_REPO_FILE}"
echo "name=Salt Repo for Salt v3007 STS" >> "${ZYPPER_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}"
echo "priority=10" >> "${ZYPPER_REPO_FILE}"
echo "enabled=1" >> "${ZYPPER_REPO_FILE}"
echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}"
echo "exclude=*3006* *3008* *3009* *3010*" >> "${ZYPPER_REPO_FILE}"
echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}"
zypper addlock "salt-* < 3007" && zypper addlock "salt-* >= 3008"
else
# Salt 3006 repo
echo "[salt-repo-3006-lts]" > "${ZYPPER_REPO_FILE}"
echo "name=Salt Repo for Salt v3006 LTS" >> "${ZYPPER_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}"
echo "priority=10" >> "${ZYPPER_REPO_FILE}"
echo "enabled=1" >> "${ZYPPER_REPO_FILE}"
echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}"
echo "exclude=*3007* *3008* *3009* *3010*" >> "${ZYPPER_REPO_FILE}"
echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}"
zypper addlock "salt-* < 3006" && zypper addlock "salt-* >= 3007"
fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version
ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${ZYPPER_REPO_FILE}"
echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${ZYPPER_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}"
echo "priority=10" >> "${ZYPPER_REPO_FILE}"
echo "enabled=1" >> "${ZYPPER_REPO_FILE}"
echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}"a
ONEDIR_MAJ_VER=$(echo "${ONEDIR_REV_DOT}" | awk -F '.' '{print $1}')
# shellcheck disable=SC2004
ONEDIR_MAJ_VER_PLUS=$((${ONEDIR_MAJ_VER} + 1))
zypper addlock "salt-* < ${ONEDIR_MAJ_VER}" && zypper addlock "salt-* >= ${ONEDIR_MAJ_VER_PLUS}"
fi
else
# Enable the Salt LATEST repo
echo "[salt-repo-latest]" > "${ZYPPER_REPO_FILE}"
echo "name=Salt Repo for Salt LATEST release" >> "${ZYPPER_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${ZYPPER_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${ZYPPER_REPO_FILE}"
echo "priority=10" >> "${ZYPPER_REPO_FILE}"
echo "enabled=1" >> "${ZYPPER_REPO_FILE}"
echo "enabled_metadata=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgcheck=1" >> "${ZYPPER_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${ZYPPER_REPO_FILE}"
fi
__zypper addrepo --refresh "${ZYPPER_REPO_FILE}" || return 1
fi fi
} }
__version_lte() { __version_lte() {
if ! __check_command_exists python; then if ! __check_command_exists python3; then
zypper --non-interactive install --replacefiles --auto-agree-with-licenses python || \ zypper --non-interactive install --replacefiles --auto-agree-with-licenses python3 || \
zypper --non-interactive install --auto-agree-with-licenses python || return 1 zypper --non-interactive install --auto-agree-with-licenses python3 || return 1
fi fi
if [ "$(${_PY_EXE} -c 'import sys; V1=tuple([int(i) for i in sys.argv[1].split(".")]); V2=tuple([int(i) for i in sys.argv[2].split(".")]); print(V1<=V2)' "$1" "$2")" = "True" ]; then if [ "$(${_PY_EXE} -c 'import sys; V1=tuple([int(i) for i in sys.argv[1].split(".")]); V2=tuple([int(i) for i in sys.argv[2].split(".")]); print(V1<=V2)' "$1" "$2")" = "True" ]; then
@ -6707,8 +6768,6 @@ __zypper_install() {
__opensuse_prep_install() { __opensuse_prep_install() {
# DRY function for common installation preparatory steps for SUSE # DRY function for common installation preparatory steps for SUSE
if [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then if [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then
# Is the repository already known
__set_suse_pkg_repo
# Check zypper repos and refresh if necessary # Check zypper repos and refresh if necessary
__check_and_refresh_suse_pkg_repo __check_and_refresh_suse_pkg_repo
fi fi
@ -6795,7 +6854,8 @@ install_opensuse_stable() {
MINOR_VER_STRG="" MINOR_VER_STRG=""
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# Minor version Salt, need to add specific minor version # Minor version Salt, need to add specific minor version
MINOR_VER_STRG="-$STABLE_REV" STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
MINOR_VER_STRG="-$STABLE_REV_DOT"
else else
MINOR_VER_STRG="" MINOR_VER_STRG=""
fi fi
@ -7110,12 +7170,94 @@ install_suse_15_restart_daemons() {
return 0 return 0
} }
install_suse_15_check_services() {
install_opensuse_check_services || return 1
return 0
}
# #
# End of SUSE Enterprise 15 # End of SUSE Enterprise 15
# #
####################################################################################################################### #######################################################################################################################
#######################################################################################################################
#
# SUSE Enterprise 15, now has ID sled
#
install_sled_15_stable_deps() {
__opensuse_prep_install || return 1
install_opensuse_15_stable_deps || return 1
return 0
}
install_sled_15_git_deps() {
install_suse_15_stable_deps || return 1
if ! __check_command_exists git; then
__zypper_install git-core || return 1
fi
install_opensuse_15_git_deps || return 1
return 0
}
install_sled_15_onedir_deps() {
__opensuse_prep_install || return 1
install_opensuse_15_onedir_deps || return 1
return 0
}
install_sled_15_stable() {
install_opensuse_stable || return 1
return 0
}
install_sled_15_git() {
install_opensuse_15_git || return 1
return 0
}
install_sled_15_onedir() {
install_opensuse_stable || return 1
return 0
}
install_sled_15_stable_post() {
install_opensuse_stable_post || return 1
return 0
}
install_sled_15_git_post() {
install_opensuse_git_post || return 1
return 0
}
install_sled_15_onedir_post() {
install_opensuse_stable_post || return 1
return 0
}
install_sled_15_restart_daemons() {
install_opensuse_restart_daemons || return 1
return 0
}
install_sled_15_check_services() {
install_opensuse_check_services || return 1
return 0
}
#
# End of SUSE Enterprise 15 aka sled
#
#######################################################################################################################
####################################################################################################################### #######################################################################################################################
# #
# Gentoo Install Functions. # Gentoo Install Functions.

View file

@ -1,39 +1,31 @@
function Convert-PSObjectToHashtable { <#
param ( .SYNOPSIS
[Parameter(ValueFromPipeline)] A simple Powershell script to quickly start using Salt.
$InputObject
)
if ($null -eq $InputObject) { return $null }
$is_enum = $InputObject -is [System.Collections.IEnumerable] .DESCRIPTION
$not_string = $InputObject -isnot [string] This script will download the latest onedir version of Salt and extract it
if ($is_enum -and $not_string) { into the same directory where the script is run. The script sets up an
$collection = @( environment that will allow you to run salt-call commands. To remove, just
foreach ($object in $InputObject) { delete the `salt` directory. The environment variables will only be set for
Convert-PSObjectToHashtable $object the current powershell session.
}
)
Write-Host -NoEnumerate $collection .EXAMPLE
} elseif ($InputObject -is [PSObject]) { ./salt-quick-start.ps1
$hash = @{}
foreach ($property in $InputObject.PSObject.Properties) { .LINK
$hash[$property.Name] = Convert-PSObjectToHashtable $property.Value Salt Bootstrap GitHub Project (script home) - https://github.com/saltstack/salt-bootstrap
} Original Vagrant Provisioner Project - https://github.com/saltstack/salty-vagrant
Vagrant Project (utilizes this script) - https://github.com/mitchellh/vagrant
Salt Download Location - https://packages.broadcom.com/artifactory/saltproject-generic/windows/
Salt Manual Install Directions (Windows) - https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html
#>
$hash # This is so the -Verbose parameter will work
} else { [CmdletBinding()] param()
$InputObject
}
}
function Expand-ZipFile { function Expand-ZipFile {
# Extract a zip file # Extract a zip file
# #
# Used by:
# - Install-SaltMinion
#
# Args: # Args:
# ZipFile (string): The file to extract # ZipFile (string): The file to extract
# Destination (string): The location to extract to # Destination (string): The location to extract to
@ -81,60 +73,151 @@ function Expand-ZipFile {
Write-Debug "Finished unzipping '$ZipFile' to '$Destination'" Write-Debug "Finished unzipping '$ZipFile' to '$Destination'"
} }
function Get-FileHash {
# Get-FileHash is a built-in cmdlet in powershell 5+ but we need to support
# powershell 3. This will overwrite the powershell 5 commandlet only for
# this script. But it will provide the missing cmdlet for powershell 3
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[String] $Path,
[Parameter(Mandatory=$false)]
[ValidateSet(
"SHA1",
"SHA256",
"SHA384",
"SHA512",
# https://serverfault.com/questions/820300/
# why-isnt-mactripledes-algorithm-output-in-powershell-stable
"MACTripleDES", # don't use
"MD5",
"RIPEMD160",
IgnoreCase=$true)]
[String] $Algorithm = "SHA256"
)
if ( !(Test-Path $Path) ) {
Write-Verbose "Invalid path for hashing: $Path"
return @{}
}
if ( (Get-Item -Path $Path) -isnot [System.IO.FileInfo]) {
Write-Verbose "Not a file for hashing: $Path"
return @{}
}
$Path = Resolve-Path -Path $Path
Switch ($Algorithm) {
SHA1 {
$hasher = [System.Security.Cryptography.SHA1CryptoServiceProvider]::Create()
}
SHA256 {
$hasher = [System.Security.Cryptography.SHA256]::Create()
}
SHA384 {
$hasher = [System.Security.Cryptography.SHA384]::Create()
}
SHA512 {
$hasher = [System.Security.Cryptography.SHA512]::Create()
}
MACTripleDES {
$hasher = [System.Security.Cryptography.MACTripleDES]::Create()
}
MD5 {
$hasher = [System.Security.Cryptography.MD5]::Create()
}
RIPEMD160 {
$hasher = [System.Security.Cryptography.RIPEMD160]::Create()
}
}
Write-Verbose "Hashing using $Algorithm algorithm"
try {
$data = [System.IO.File]::OpenRead($Path)
$hash = $hasher.ComputeHash($data)
$hash = [System.BitConverter]::ToString($hash) -replace "-",""
return @{
Path = $Path;
Algorithm = $Algorithm.ToUpper();
Hash = $hash
}
} catch {
Write-Verbose "Error hashing: $Path"
Write-Verbose "ERROR: $_"
return @{}
} finally {
if ($null -ne $data) {
$data.Close()
}
}
}
#===============================================================================
# Script settings
#===============================================================================
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls12' [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls12'
$global:ProgressPreference = 'SilentlyContinue' $global:ProgressPreference = 'SilentlyContinue'
$RepoUrl = "https://repo.saltproject.io/salt/py3/onedir" #===============================================================================
# Declare Variables
#===============================================================================
$ApiUrl = "https://packages.broadcom.com/artifactory/api/storage/saltproject-generic/onedir"
# Detect architecture ($arch)
if ([IntPtr]::Size -eq 4) { $arch = "x86" } else { $arch = "amd64" }
if ([IntPtr]::Size -eq 4) { #===============================================================================
$arch = "x86" # Setting up quickstart environment
} else { #===============================================================================
$arch = "amd64" Write-Host ""
} Write-Host "Setting up quickstart environment for Salt" -ForegroundColor Cyan
$enc = [System.Text.Encoding]::UTF8
try {
$response = Invoke-WebRequest -Uri "$RepoUrl/repo.json" -UseBasicParsing
if ($response.Content.GetType().Name -eq "Byte[]") {
$psobj = $enc.GetString($response.Content) | ConvertFrom-Json
} else { Write-Verbose "Getting version information from Artifactory"
$psobj = $response.Content | ConvertFrom-Json $response = Invoke-WebRequest $ApiUrl -UseBasicParsing
} # Convert the output to a powershell object
$hash = Convert-PSObjectToHashtable $psobj $psobj = $response.ToString() | ConvertFrom-Json
} catch { $Version = $psobj.children[-1].uri.Trim("/")
Write-Host "repo.json not found at: $RepoUrl"
$hash = @{}
}
$searchVersion = "latest"
if ( $hash.Contains($searchVersion)) {
foreach ($item in $hash.($searchVersion).Keys) {
if ( $item.EndsWith(".zip") ) {
if ( $item.Contains($arch) ) {
$saltFileName = $hash.($searchVersion).($item).name
$saltVersion = $hash.($searchVersion).($item).version
$saltSha512 = $hash.($searchVersion).($item).SHA512
}
}
}
}
if ( $saltFileName -and $saltVersion -and $saltSha512 ) {
if ( $RepoUrl.Contains("minor") ) {
$saltFileUrl = @($RepoUrl, $saltVersion, $saltFileName) -join "/"
} else {
$saltFileUrl = @($RepoUrl, "minor", $saltVersion, $saltFileName) -join "/"
}
}
Write-Host "* INFO: Downloading Salt" Write-Verbose "Getting sha256 hash and download url from Artifactory"
$saltFileName = "salt-$Version-onedir-windows-$arch.zip"
$response = Invoke-WebRequest "$ApiUrl/$Version/$saltFileName" -UseBasicParsing
$psobj = $response.ToString() | ConvertFrom-Json
$saltFileUrl = $psobj.downloadUri
$saltSha256 = $psobj.checksums.sha256
Write-Verbose "URL: $saltFileUrl"
Write-Host "* INFO: Downloading Salt: " -NoNewline
Invoke-WebRequest -Uri $saltFileUrl -OutFile .\salt.zip Invoke-WebRequest -Uri $saltFileUrl -OutFile .\salt.zip
if ( Test-Path -Path .\salt.zip ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
$localSha256 = (Get-FileHash -Path .\salt.zip -Algorithm SHA256).Hash
Write-Verbose "Local Hash: $localSha256"
Write-Verbose "Remote Hash: $saltSha256"
Write-Host "* INFO: Extracting Salt" Write-Host "* INFO: Comparing Hash: " -NoNewline
if ( $localSha256 -eq $saltSha256 ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "* INFO: Extracting Salt: " -NoNewline
Expand-ZipFile -ZipFile .\salt.zip -Destination . Expand-ZipFile -ZipFile .\salt.zip -Destination .
if ( Test-Path -Path .\salt\Scripts\python.exe ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "* INFO: Creating Saltfile: " -NoNewline
$PATH = $(Get-Location).Path $PATH = $(Get-Location).Path
$saltfile_contents = @" $saltfile_contents = @"
salt-call: salt-call:
local: True local: True
@ -143,20 +226,42 @@ salt-call:
cachedir: $PATH\salt\var\cache\salt cachedir: $PATH\salt\var\cache\salt
file_root: $PATH\salt\srv\salt file_root: $PATH\salt\srv\salt
"@ "@
Set-Content -Path .\salt\Saltfile -Value $saltfile_contents Set-Content -Path .\salt\Saltfile -Value $saltfile_contents
if ( Test-Path -Path .\salt\Saltfile ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
New-Item -Path "$PATH\salt\var\log\salt" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\var\log\salt" -Type Directory -Force | Out-Null
New-Item -Path "$PATH\salt\conf" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\conf" -Type Directory -Force | Out-Null
New-Item -Path "$PATH\salt\var\cache\salt" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\var\cache\salt" -Type Directory -Force | Out-Null
New-Item -Path "$PATH\salt\srv\salt" -Type Directory -Force | Out-Null New-Item -Path "$PATH\salt\srv\salt" -Type Directory -Force | Out-Null
Write-Host "* INFO: Adding Salt to current path" Write-Host "* INFO: Adding Salt to current path: " -NoNewline
Write-Host "* INFO: $PATH\salt"
$env:Path = "$PATH\salt;$env:PATH" $env:Path = "$PATH\salt;$env:PATH"
Write-Verbose $env:Path
if ( $env:PATH -Like "*$PATH\salt*" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "* INFO: $PATH\salt"
Write-Host "* INFO: Setting the SALT_SALTFILE environment variable" Write-Host "* INFO: Setting the SALT_SALTFILE environment variable: "-NoNewline
Write-Host "* INFO: $PATH\salt\Saltfile"
$env:SALT_SALTFILE="$PATH\salt\Saltfile" $env:SALT_SALTFILE="$PATH\salt\Saltfile"
if ( Test-Path -Path $env:SALT_SALTFILE ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "* INFO: $PATH\salt\Saltfile"
Write-Host ""
Write-Host "You can now run simple salt-call commands" -ForegroundColor Cyan
Write-Host "* INFO: Create Salt states in $PATH\salt\srv\salt" Write-Host "* INFO: Create Salt states in $PATH\salt\srv\salt"
Write-Host "* INFO: Try running salt-call test.ping"
Write-Host ""