Bug 2005754

Summary: Issue while registering the RHEL 6 Host using new Satellite Server Token Registration Steps.
Product: Red Hat Satellite Reporter: Surjeet Salvi <susalvi>
Component: RegistrationAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Stephen Wadeley <swadeley>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.9.0CC: lstejska, satellite6-bugs, zhunting
Target Milestone: 6.10.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-2.5.2.13-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 14:13:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Surjeet Salvi 2021-09-20 04:47:22 UTC
DESCRIPTION OF PROBLEM:
- Unable to register the RHEL 6 host using new Satellite Server Token Registration Steps

Version-Release number of selected component (if applicable):
- Satellite 6.9.5

HOW TO REPRODUCE:

- Create Token from Satellite WEBUI and try to register
# curl --insecure -X GET "https://satellite.example.com:9090/register?activation_key=test&hostgroup_id=2&location_id=2&operatingsystem_id=6&organization_id=1&setup_insights=false&setup_remote_execution=false" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MzIwOTk5NTIsImp0aSI6IjVkODFkZjc2NTcxYjEzNjgyY2QzMTk3MzhlNzljMTljMzY2NWNiZWU3YTg2OTAxOTAzODFkYjRjMTZmYTYwZGQiLCJleHAiOjE2MzIxMTQzNTJ9.XBICWN-Ut3Yc6n3AoGCBizeX2791kh8isqxZSiCc43Y' | bash

ACTUAL RESULT:

- Blank host profile is getting created on Red Hat Satellite WEBUI. 
- Host is not getting registered in actual

EXPECTED RESULT:

- Host should get register with the Red Hat Satellite server. 


ADDITIONAL INFORMATION:

- After reviewing the background script it is looking for file /etc/os-release and pulling the ID from it

+++++++
if ! [ $(id -u) = 0 ]; then
    echo "Please run as root"
    exit 1
fi

if [ -f /etc/os-release ] ; then
  . /etc/os-release
fi


if [ x$ID = xrhel ] || [ x$ID = xcentos ]; then
    register_katello_host(){
        UUID=$(subscription-manager identity | head -1 | awk '{print $3}')
        curl --cacert $SSL_CA_CERT --request POST "https://susalvi-rhsat.syslab.pnq2.redhat.com:9090/register" \
             --data "uuid=$UUID" \
            -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MzIxMDY3OTksImp0aSI6ImU3NTI2N2U1OGU4OGVkZjc4ZTViNzdjODcyNThiNjk3MGY4ZGQ2N2RhNmQxZjExNjM4ZTk5Y2ZmYzdhNjIxNmEiLCJleHAiOjE2MzIxMjExOTl9.kqpnGBJBFarmR6WBAQVrGdpGTg59jGA0tR3LsnR6V0U' \
            --data "host[organization_id]=1"            --data "host[location_id]=2"            --data "host[hostgroup_id]=2"            --data "setup_insights=false"            --data "setup_remote_execution=false"            
    }

    CONSUMER_RPM=$(mktemp --suffix .rpm)
    curl --output $CONSUMER_RPM http://susalvi-rhsat.syslab.pnq2.redhat.com/pub/katello-ca-consumer-latest.noarch.rpm
    yum localinstall $CONSUMER_RPM -y
    rm -f $CONSUMER_RPM

    subscription-manager register --org='RedHat' --activationkey='test' || exit 1
    register_katello_host | bash
else
    register_host | bash


- Since the/etc/os-release file is not present on the RHEL 6 host, it is only creating the blank host profile and skipping the actual registration part.


WORKAROUND - 
 
- Manually create the file "/etc/os-release" with the below details. 

++++++++
NAME="Red Hat Enterprise Linux Server"
VERSION="6.10 (Santiago)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="6.10"
++++++++

- Now execute the below curl command and it will register the host successfully.

# curl --insecure -X GET "https://satellite.example.com:9090/register?activation_key=test&hostgroup_id=2&location_id=2&operatingsystem_id=6&organization_id=1&setup_insights=false&setup_remote_execution=false" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MzIwOTk5NTIsImp0aSI6IjVkODFkZjc2NTcxYjEzNjgyY2QzMTk3MzhlNzljMTljMzY2NWNiZWU3YTg2OTAxOTAzODFkYjRjMTZmYTYwZGQiLCJleHAiOjE2MzIxMTQzNTJ9.XBICWN-Ut3Yc6n3AoGCBizeX2791kh8isqxZSiCc43Y' | bash

Comment 1 Leos Stejskal 2021-09-20 06:30:11 UTC
Hi,
this is expected behavior, we rely on /etc/os-release file,
for systems that doesn't have this file we register machine with minimal data.

Anyway this issue should be fixed in https://github.com/theforeman/foreman/pull/8774,
where we use `/etc/redhat-release` instead of `/etc/os-release`.

Comment 8 errata-xmlrpc 2021-11-16 14:13:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.10 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:4702