Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37627 - Only update repositories once in global registration #10237

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ name=foreman_register<%= index %>
baseurl=<%= shell_escape repo %>
enabled=1
type=rpm-md
EOF
<% if repo_gpg_key_url.present? -%>
echo gpgcheck=1 >> /tmp/foreman_registration.repo
echo gpgkey=<%= shell_escape repo_gpg_key_url %> >> /tmp/foreman_registration.repo
gpgcheck=1
gpgkey=<%= shell_escape repo_gpg_key_url %>
<% else -%>
echo gpgcheck=0 >> /tmp/foreman_registration.repo
gpgcheck=0
<% end -%>
EOF
if [ x$PKG_MANAGER = xdnf -o x$PKG_MANAGER = xyum ]; then
mv -f /tmp/foreman_registration.repo /etc/yum.repos.d/foreman_registration<%= index %>.repo
echo "Building yum metadata cache, this may take a few minutes"
$PKG_MANAGER makecache
else
zypper --quiet --non-interactive addrepo /tmp/foreman_registration.repo
fi
Expand All @@ -98,13 +96,18 @@ elif [ -f /etc/debian_version ]; then
curl --silent --show-error --output /etc/apt/trusted.gpg.d/client<%= index %>.asc <%= shell_escape repo_gpg_key_url %>
fi
<% end -%>
apt-get update

else
echo "Unsupported operating system, can't add repository."
cleanup_and_exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fi
fi

While you are at it, you could add a newline such that the code blocks that configure a repository will be separated by a newline in the resulting shell script.

<% end -%>

if [ x$PKG_MANAGER = xdnf -o x$PKG_MANAGER = xyum ]; then
echo "Building yum metadata cache, this may take a few minutes"
$PKG_MANAGER makecache
elif [ -f /etc/debian_version ]; then
apt-get update
fi
<% end -%>

register_host() {
Expand Down
Loading