Skip to content

Commit

Permalink
Merge pull request #2070 from dmurphy18/fix_amzn2_yum
Browse files Browse the repository at this point in the history
Restrict use of dnf to Fedora only, otherwise use yum when dealing with RedHat family
  • Loading branch information
dmurphy18 authored Dec 11, 2024
2 parents 54243fe + a4c8423 commit fa5ae44
Showing 1 changed file with 126 additions and 35 deletions.
161 changes: 126 additions & 35 deletions bootstrap-salt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4224,8 +4224,8 @@ __install_saltstack_rhel_onedir_repository() {
REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1)
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
# Enable the Salt 3007 STS repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-3007-sts
yum config-manager --set-disable salt-repo-*
yum config-manager --set-enabled salt-repo-3007-sts
fi
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version
Expand All @@ -4243,11 +4243,11 @@ __install_saltstack_rhel_onedir_repository() {
fi
else
# Enable the Salt LATEST repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-latest
yum config-manager --set-disable salt-repo-*
yum config-manager --set-enabled salt-repo-latest
fi
dnf clean expire-cache || return 1
dnf makecache || return 1
yum clean expire-cache || return 1
yum makecache || return 1
elif [ "$ONEDIR_REV" != "latest" ]; then
echowarn "salt.repo already exists, ignoring salt version argument."
echowarn "Use -F (forced overwrite) to install $ONEDIR_REV."
Expand Down Expand Up @@ -4559,8 +4559,8 @@ install_centos_onedir() {
fi

# shellcheck disable=SC2086
dnf makecache || return 1
dnf list salt-minion || return 1
yum makecache || return 1
yum list salt-minion || return 1
__yum_install_noinput ${__PACKAGES} || return 1

return 0
Expand Down Expand Up @@ -5652,23 +5652,44 @@ install_amazon_linux_ami_2_deps() {

if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
if [ ! -s "${YUM_REPO_FILE}" ]; then
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
## Amazon Linux yum (v3) doesn't support config-manager
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
# shellcheck disable=SC2129
if [ "$STABLE_REV" != "latest" ]; then
# 3006.x is default, and latest for 3006.x branch
if [ "$(echo "$STABLE_REV" | grep -E '^(3006|3007)$')" != "" ]; then
# latest version for branch 3006 | 3007
REPO_REV_MAJOR=$(echo "$STABLE_REV" | cut -d '.' -f 1)
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
# Enable the Salt 3007 STS repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-3007-sts
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
else
# Salt 3006 repo
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
fi
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
# using minor version
STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
echo "[salt-repo-${STABLE_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129
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 "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
Expand All @@ -5680,11 +5701,18 @@ install_amazon_linux_ami_2_deps() {
fi
else
# Enable the Salt LATEST repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-latest
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
fi
dnf clean expire-cache || return 1
dnf makecache || return 1
yum clean expire-cache || return 1
yum makecache || return 1
fi
fi

Expand Down Expand Up @@ -5717,23 +5745,44 @@ install_amazon_linux_ami_2_onedir_deps() {

if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
if [ ! -s "${YUM_REPO_FILE}" ]; then
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
## Amazon Linux yum (v3) doesn't support config-manager
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
# 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
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-3007-sts
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
else
# Salt 3006 repo
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
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]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129
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 "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
Expand All @@ -5745,11 +5794,18 @@ install_amazon_linux_ami_2_onedir_deps() {
fi
else
# Enable the Salt LATEST repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-latest
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
fi
dnf clean expire-cache || return 1
dnf makecache || return 1
yum clean expire-cache || return 1
yum makecache || return 1
fi
fi

Expand Down Expand Up @@ -5852,6 +5908,13 @@ install_amazon_linux_ami_2023_git_deps() {
return 0
}

install_amazon_linux_ami_2023_deps() {

# Set ONEDIR_REV to STABLE_REV
ONEDIR_REV=${STABLE_REV}
install_amazon_linux_ami_2023_onedir_deps || return 1
}

install_amazon_linux_ami_2023_onedir_deps() {

# We need to install yum-utils before doing anything else when installing on
Expand All @@ -5870,23 +5933,44 @@ install_amazon_linux_ami_2023_onedir_deps() {

if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
if [ ! -s "${YUM_REPO_FILE}" ]; then
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
## Amazon Linux yum (v3) doesn't support config-manager
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
# 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
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-3007-sts
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
else
# Salt 3006 repo
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
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]" > "${YUM_REPO_FILE}"
# shellcheck disable=SC2129
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 "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
Expand All @@ -5898,11 +5982,18 @@ install_amazon_linux_ami_2023_onedir_deps() {
fi
else
# Enable the Salt LATEST repo
dnf config-manager --set-disable salt-repo-*
dnf config-manager --set-enabled salt-repo-latest
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
echo "priority=10" >> "${YUM_REPO_FILE}"
echo "enabled=1" >> "${YUM_REPO_FILE}"
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
fi
dnf clean expire-cache || return 1
dnf makecache || return 1
yum clean expire-cache || return 1
yum makecache || return 1
fi
fi

Expand Down

0 comments on commit fa5ae44

Please sign in to comment.