From 102250843357e9485cd57e0a9403b825b9c83245 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 3 Mar 2025 09:39:05 -0800 Subject: [PATCH] Fix breaking changes in non-core repos Commit e6f817cba5057870c29b9dd220a048914d0c33a7 introduced a breaking change when downloading the GPG key from non-core repos on SLES. It also incorrectly attempted to manage credentials for non-core repos for all rpm-based platforms. This commit restores the GPG location on yum.puppet.com and guards the sed commands to only run when the repo collection contains "core" --- tasks/install_shell.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks/install_shell.sh b/tasks/install_shell.sh index 73104f9b..cd625215 100644 --- a/tasks/install_shell.sh +++ b/tasks/install_shell.sh @@ -602,11 +602,13 @@ install_file() { repo="/etc/yum.repos.d/${collection/core/}-release.repo" rpm -Uvh --oldpackage --replacepkgs "$2" - if [[ -n $username ]]; then + if [[ "$collection" =~ core ]]; then + if [[ -n $username ]]; then sed -i "s/^#\?username=.*/username=${username}/" "${repo}" - fi - if [[ -n $password ]]; then + fi + if [[ -n $password ]]; then sed -i "s/^#\?password=.*/password=${password}/" "${repo}" + fi fi exists dnf && PKGCMD=dnf || PKGCMD=yum if test "$version" = 'latest'; then @@ -632,11 +634,13 @@ install_file() { fi run_cmd "zypper install --no-confirm '$2'" - if [[ -n $username ]]; then + if [[ "$collection" =~ core ]]; then + if [[ -n $username ]]; then sed -i "s/^username=.*/username=${username}/" "/etc/zypp/credentials.d/PuppetcoreCreds" - fi - if [[ -n $password ]]; then + fi + if [[ -n $password ]]; then sed -i "s/^password=.*/password=${password}/" "/etc/zypp/credentials.d/PuppetcoreCreds" + fi fi if test "$version" = "latest"; then run_cmd "zypper install --no-confirm 'puppet-agent'" @@ -700,7 +704,7 @@ case $platform in info "SLES platform! Lets get you an RPM..." if [[ $PT__noop != true ]]; then - if [[ "$PT_collection" =~ core ]]; then + if [[ "$collection" =~ core ]]; then for key in "puppet"; do gpg_key="${tmp_dir}/RPM-GPG-KEY-${key}" do_download "https://yum-puppetcore.puppet.com/public/RPM-GPG-KEY-${key}" "$gpg_key" @@ -710,7 +714,7 @@ case $platform in else for key in "puppet" "puppet-20250406"; do gpg_key="${tmp_dir}/RPM-GPG-KEY-${key}" - do_download "https://yum.puppet.com/public/RPM-GPG-KEY-${key}" "$gpg_key" + do_download "https://yum.puppet.com/RPM-GPG-KEY-${key}" "$gpg_key" rpm --import "$gpg_key" rm -f "$gpg_key" done