Skip to content

Commit fa5ae44

Browse files
authored
Merge pull request #2070 from dmurphy18/fix_amzn2_yum
Restrict use of dnf to Fedora only, otherwise use yum when dealing with RedHat family
2 parents 54243fe + a4c8423 commit fa5ae44

1 file changed

Lines changed: 126 additions & 35 deletions

File tree

bootstrap-salt.sh

Lines changed: 126 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,8 +4224,8 @@ __install_saltstack_rhel_onedir_repository() {
42244224
REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1)
42254225
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
42264226
# Enable the Salt 3007 STS repo
4227-
dnf config-manager --set-disable salt-repo-*
4228-
dnf config-manager --set-enabled salt-repo-3007-sts
4227+
yum config-manager --set-disable salt-repo-*
4228+
yum config-manager --set-enabled salt-repo-3007-sts
42294229
fi
42304230
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
42314231
# using minor version
@@ -4243,11 +4243,11 @@ __install_saltstack_rhel_onedir_repository() {
42434243
fi
42444244
else
42454245
# Enable the Salt LATEST repo
4246-
dnf config-manager --set-disable salt-repo-*
4247-
dnf config-manager --set-enabled salt-repo-latest
4246+
yum config-manager --set-disable salt-repo-*
4247+
yum config-manager --set-enabled salt-repo-latest
42484248
fi
4249-
dnf clean expire-cache || return 1
4250-
dnf makecache || return 1
4249+
yum clean expire-cache || return 1
4250+
yum makecache || return 1
42514251
elif [ "$ONEDIR_REV" != "latest" ]; then
42524252
echowarn "salt.repo already exists, ignoring salt version argument."
42534253
echowarn "Use -F (forced overwrite) to install $ONEDIR_REV."
@@ -4559,8 +4559,8 @@ install_centos_onedir() {
45594559
fi
45604560

45614561
# shellcheck disable=SC2086
4562-
dnf makecache || return 1
4563-
dnf list salt-minion || return 1
4562+
yum makecache || return 1
4563+
yum list salt-minion || return 1
45644564
__yum_install_noinput ${__PACKAGES} || return 1
45654565

45664566
return 0
@@ -5652,23 +5652,44 @@ install_amazon_linux_ami_2_deps() {
56525652

56535653
if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
56545654
if [ ! -s "${YUM_REPO_FILE}" ]; then
5655-
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5656-
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5655+
## Amazon Linux yum (v3) doesn't support config-manager
5656+
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5657+
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5658+
# shellcheck disable=SC2129
56575659
if [ "$STABLE_REV" != "latest" ]; then
56585660
# 3006.x is default, and latest for 3006.x branch
56595661
if [ "$(echo "$STABLE_REV" | grep -E '^(3006|3007)$')" != "" ]; then
56605662
# latest version for branch 3006 | 3007
56615663
REPO_REV_MAJOR=$(echo "$STABLE_REV" | cut -d '.' -f 1)
56625664
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
56635665
# Enable the Salt 3007 STS repo
5664-
dnf config-manager --set-disable salt-repo-*
5665-
dnf config-manager --set-enabled salt-repo-3007-sts
5666+
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
5667+
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
5668+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5669+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5670+
echo "priority=10" >> "${YUM_REPO_FILE}"
5671+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5672+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5673+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5674+
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5675+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
5676+
else
5677+
# Salt 3006 repo
5678+
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
5679+
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
5680+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5681+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5682+
echo "priority=10" >> "${YUM_REPO_FILE}"
5683+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5684+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5685+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5686+
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5687+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
56665688
fi
56675689
elif [ "$(echo "$STABLE_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
56685690
# using minor version
56695691
STABLE_REV_DOT=$(echo "$STABLE_REV" | sed 's/-/\./')
56705692
echo "[salt-repo-${STABLE_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
5671-
# shellcheck disable=SC2129
56725693
echo "name=Salt Repo for Salt v${STABLE_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
56735694
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
56745695
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
@@ -5680,11 +5701,18 @@ install_amazon_linux_ami_2_deps() {
56805701
fi
56815702
else
56825703
# Enable the Salt LATEST repo
5683-
dnf config-manager --set-disable salt-repo-*
5684-
dnf config-manager --set-enabled salt-repo-latest
5704+
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
5705+
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
5706+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5707+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5708+
echo "priority=10" >> "${YUM_REPO_FILE}"
5709+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5710+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5711+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5712+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
56855713
fi
5686-
dnf clean expire-cache || return 1
5687-
dnf makecache || return 1
5714+
yum clean expire-cache || return 1
5715+
yum makecache || return 1
56885716
fi
56895717
fi
56905718

@@ -5717,23 +5745,44 @@ install_amazon_linux_ami_2_onedir_deps() {
57175745

57185746
if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
57195747
if [ ! -s "${YUM_REPO_FILE}" ]; then
5720-
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5721-
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5748+
## Amazon Linux yum (v3) doesn't support config-manager
5749+
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5750+
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5751+
# shellcheck disable=SC2129
57225752
if [ "$ONEDIR_REV" != "latest" ]; then
57235753
# 3006.x is default, and latest for 3006.x branch
57245754
if [ "$(echo "$ONEDIR_REV" | grep -E '^(3006|3007)$')" != "" ]; then
57255755
# latest version for branch 3006 | 3007
57265756
REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1)
57275757
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
57285758
# Enable the Salt 3007 STS repo
5729-
dnf config-manager --set-disable salt-repo-*
5730-
dnf config-manager --set-enabled salt-repo-3007-sts
5759+
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
5760+
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
5761+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5762+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5763+
echo "priority=10" >> "${YUM_REPO_FILE}"
5764+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5765+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5766+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5767+
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5768+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
5769+
else
5770+
# Salt 3006 repo
5771+
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
5772+
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
5773+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5774+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5775+
echo "priority=10" >> "${YUM_REPO_FILE}"
5776+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5777+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5778+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5779+
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5780+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
57315781
fi
57325782
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
57335783
# using minor version
57345784
ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
57355785
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
5736-
# shellcheck disable=SC2129
57375786
echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
57385787
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
57395788
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
@@ -5745,11 +5794,18 @@ install_amazon_linux_ami_2_onedir_deps() {
57455794
fi
57465795
else
57475796
# Enable the Salt LATEST repo
5748-
dnf config-manager --set-disable salt-repo-*
5749-
dnf config-manager --set-enabled salt-repo-latest
5797+
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
5798+
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
5799+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5800+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5801+
echo "priority=10" >> "${YUM_REPO_FILE}"
5802+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5803+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5804+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5805+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
57505806
fi
5751-
dnf clean expire-cache || return 1
5752-
dnf makecache || return 1
5807+
yum clean expire-cache || return 1
5808+
yum makecache || return 1
57535809
fi
57545810
fi
57555811

@@ -5852,6 +5908,13 @@ install_amazon_linux_ami_2023_git_deps() {
58525908
return 0
58535909
}
58545910

5911+
install_amazon_linux_ami_2023_deps() {
5912+
5913+
# Set ONEDIR_REV to STABLE_REV
5914+
ONEDIR_REV=${STABLE_REV}
5915+
install_amazon_linux_ami_2023_onedir_deps || return 1
5916+
}
5917+
58555918
install_amazon_linux_ami_2023_onedir_deps() {
58565919

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

58715934
if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
58725935
if [ ! -s "${YUM_REPO_FILE}" ]; then
5873-
FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5874-
__fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5936+
## Amazon Linux yum (v3) doesn't support config-manager
5937+
## FETCH_URL="https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo"
5938+
## __fetch_url "${YUM_REPO_FILE}" "${FETCH_URL}"
5939+
# shellcheck disable=SC2129
58755940
if [ "$ONEDIR_REV" != "latest" ]; then
58765941
# 3006.x is default, and latest for 3006.x branch
58775942
if [ "$(echo "$ONEDIR_REV" | grep -E '^(3006|3007)$')" != "" ]; then
58785943
# latest version for branch 3006 | 3007
58795944
REPO_REV_MAJOR=$(echo "$ONEDIR_REV" | cut -d '.' -f 1)
58805945
if [ "$REPO_REV_MAJOR" -eq "3007" ]; then
58815946
# Enable the Salt 3007 STS repo
5882-
dnf config-manager --set-disable salt-repo-*
5883-
dnf config-manager --set-enabled salt-repo-3007-sts
5947+
echo "[salt-repo-3007-sts]" > "${YUM_REPO_FILE}"
5948+
echo "name=Salt Repo for Salt v3007 STS" >> "${YUM_REPO_FILE}"
5949+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5950+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5951+
echo "priority=10" >> "${YUM_REPO_FILE}"
5952+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5953+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5954+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5955+
echo "exclude=*3006* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5956+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
5957+
else
5958+
# Salt 3006 repo
5959+
echo "[salt-repo-3006-lts]" > "${YUM_REPO_FILE}"
5960+
echo "name=Salt Repo for Salt v3006 LTS" >> "${YUM_REPO_FILE}"
5961+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5962+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5963+
echo "priority=10" >> "${YUM_REPO_FILE}"
5964+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5965+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5966+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5967+
echo "exclude=*3007* *3008* *3009* *3010*" >> "${YUM_REPO_FILE}"
5968+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
58845969
fi
58855970
elif [ "$(echo "$ONEDIR_REV" | grep -E '^([3-9][0-5]{2}[6-9](\.[0-9]*)?)')" != "" ]; then
58865971
# using minor version
58875972
ONEDIR_REV_DOT=$(echo "$ONEDIR_REV" | sed 's/-/\./')
58885973
echo "[salt-repo-${ONEDIR_REV_DOT}-lts]" > "${YUM_REPO_FILE}"
5889-
# shellcheck disable=SC2129
58905974
echo "name=Salt Repo for Salt v${ONEDIR_REV_DOT} LTS" >> "${YUM_REPO_FILE}"
58915975
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
58925976
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
@@ -5898,11 +5982,18 @@ install_amazon_linux_ami_2023_onedir_deps() {
58985982
fi
58995983
else
59005984
# Enable the Salt LATEST repo
5901-
dnf config-manager --set-disable salt-repo-*
5902-
dnf config-manager --set-enabled salt-repo-latest
5985+
echo "[salt-repo-latest]" > "${YUM_REPO_FILE}"
5986+
echo "name=Salt Repo for Salt LATEST release" >> "${YUM_REPO_FILE}"
5987+
echo "baseurl=https://${_REPO_URL}/saltproject-rpm/" >> "${YUM_REPO_FILE}"
5988+
echo "skip_if_unavailable=True" >> "${YUM_REPO_FILE}"
5989+
echo "priority=10" >> "${YUM_REPO_FILE}"
5990+
echo "enabled=1" >> "${YUM_REPO_FILE}"
5991+
echo "enabled_metadata=1" >> "${YUM_REPO_FILE}"
5992+
echo "gpgcheck=1" >> "${YUM_REPO_FILE}"
5993+
echo "gpgkey=https://${_REPO_URL}/api/security/keypair/SaltProjectKey/public" >> "${YUM_REPO_FILE}"
59035994
fi
5904-
dnf clean expire-cache || return 1
5905-
dnf makecache || return 1
5995+
yum clean expire-cache || return 1
5996+
yum makecache || return 1
59065997
fi
59075998
fi
59085999

0 commit comments

Comments
 (0)