Skip to content

Commit

Permalink
Fixes #36938 - Ignore output of some commands in Global Registration
Browse files Browse the repository at this point in the history
(cherry picked from commit b404794)
  • Loading branch information
stejskalleos authored and Griffin-Sullivan committed Dec 5, 2023
1 parent c12216b commit 8608769
Showing 1 changed file with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,73 @@ register_katello_host(){

}

# Set up subscription-manager
<%= snippet("subscription_manager_setup", variables: { subman_setup_scenario: 'registration' }).strip -%>
KATELLO_SERVER_CA_CERT=/etc/rhsm/ca/katello-server-ca.pem
RHSM_CFG=/etc/rhsm/rhsm.conf

# Backup rhsm.conf
if [ -f $RHSM_CFG ] ; then
test -f $RHSM_CFG.bak || cp $RHSM_CFG $RHSM_CFG.bak
fi

# rhn-client-tools conflicts with subscription-manager package
# since rhn tools replaces subscription-manager, we need to explicitly
# install subscription-manager after the rhn tools cleanup
if [ x$ID = xol ]; then
$PKG_MANAGER_REMOVE rhn-client-tools
$PKG_MANAGER_INSTALL --setopt=obsoletes=0 subscription-manager
fi

<% if truthy?(@force) -%>
# Unregister host and remove all local system and subscription data

if [ -x "$(command -v subscription-manager)" ] ; then
subscription-manager unregister || true
subscription-manager clean
fi

$PKG_MANAGER_REMOVE katello-ca-consumer\* > /dev/null 2>&1
<% end -%>

# Prepare SSL certificate
mkdir -p /etc/rhsm/ca
cp -f $SSL_CA_CERT $KATELLO_SERVER_CA_CERT
chmod 644 $KATELLO_SERVER_CA_CERT

# Prepare subscription-manager
if ! [ -x "$(command -v subscription-manager)" ] ; then
$PKG_MANAGER_INSTALL subscription-manager
else
$PKG_MANAGER_UPGRADE subscription-manager > /dev/null 2>&1
fi

if ! [ -f $RHSM_CFG ] ; then
echo "'$RHSM_CFG' not found, cannot configure subscription-manager"
cleanup_and_exit 1
fi

# Configure subscription-manager
test -f $RHSM_CFG.bak || cp $RHSM_CFG $RHSM_CFG.bak
subscription-manager config \
--server.hostname="<%= @rhsm_url.host if @rhsm_url %>" \
--server.port="<%= @rhsm_url.port if @rhsm_url %>" \
--server.prefix="<%= @rhsm_url.path if @rhsm_url %>" \
--rhsm.repo_ca_cert="$KATELLO_SERVER_CA_CERT" \
--rhsm.baseurl="<%= @pulp_content_url %>"

# Older versions of subscription manager may not recognize
# report_package_profile and package_profile_on_trans options.
# So set them separately and redirect out & error to /dev/null
# to fail silently.
subscription-manager config --rhsm.package_profile_on_trans=1 > /dev/null 2>&1 || true
subscription-manager config --rhsm.report_package_profile=1 > /dev/null 2>&1 || true

# Configuration for EL6
if grep --quiet full_refresh_on_yum $RHSM_CFG; then
sed -i "s/full_refresh_on_yum\s*=.*$/full_refresh_on_yum = 1/g" $RHSM_CFG
else
full_refresh_config="#config for on-premise management\nfull_refresh_on_yum = 1"
sed -i "/baseurl/a $full_refresh_config" $RHSM_CFG
fi

subscription-manager register <%= '--force' if truthy?(@force) %> \
--org='<%= @organization.label if @organization %>' \
Expand Down

0 comments on commit 8608769

Please sign in to comment.