Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2211484 - Global Registration using an user with "Register Hosts" role ignores all the setup options.
Summary: Global Registration using an user with "Register Hosts" role ignores all the ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Registration
Version: 6.13.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.14.0
Assignee: Leos Stejskal
QA Contact: Shweta Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-05-31 18:24 UTC by Manu Sunil
Modified: 2024-02-08 18:07 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-08 14:19:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 36484 0 Normal New User with "Register Hosts" role ignores all the setup options. 2023-06-07 10:32:25 UTC
Red Hat Issue Tracker SAT-18127 0 None None None 2023-06-06 00:21:34 UTC
Red Hat Issue Tracker SAT-18208 0 None None None 2023-06-08 06:46:41 UTC
Red Hat Issue Tracker SAT-18851 0 None None None 2023-07-20 10:53:32 UTC
Red Hat Knowledge Base (Solution) 7034461 0 None None None 2023-09-22 16:15:50 UTC
Red Hat Product Errata RHSA-2023:6818 0 None None None 2023-11-08 14:19:42 UTC

Description Manu Sunil 2023-05-31 18:24:32 UTC
Description of problem:

Global Registration using an user with "Register Hosts" role ignores all the setup options.

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

- Satellite 6.13.0

How reproducible:

- Everytime

Steps to Reproduce:

1. Create a user on the Satellite with Register Hosts role.

2. Using the new user, generate a global registration command with all the Setup options set to No.

3. Execute the command on the client.

Actual results:

- The parameters in the script. 

  ~~~
  # Rendered with following template parameters:
  # User: [reg-user]
  # Organization: [RedHat]
  # Location: [Pune]
  # Setup Insights: [false]
  # Setup remote execution: [false]
  # Setup remote execution pull: [false]
  # Update packages: [false]
  # Activation keys: [GENERAL]
  ~~~

- The register command in the script.

  ~~~
  curl --silent --show-error --cacert $KATELLO_SERVER_CA_CERT --request POST "https://satellite.example.com/register" \
       --data "uuid=$UUID" \
       -H 'Authorization: Bearer XYZ \
    --data 'host[organization_id]=1' \
    --data 'host[location_id]=2' \
    --data 'setup_insights=false' \
    --data 'setup_remote_execution=false' \
    --data 'setup_remote_execution_pull=false' \
    --data 'update_packages=false'
  ~~~

- The script generated by this command still performs the setups that are set to No.

  ~~~
  #!/bin/bash
  set -e
  
  echo "# Running [client-1.example.com] host initial configuration"
  
  foreman_curl() {
    curl --silent --show-error  -o /dev/null --noproxy \* "$@"
  }
  
  exit_and_cancel_build() {
    echo 'Host [client-1.example.com] initial configuration failed'
    foreman_curl --request POST 'http://satellite.example.com/unattended/failed?token=XYZ' \
         --data 'Host initial configuration failed, please see the registration log for more details.'
    exit 1
  }
  
  set +e
  trap 'exit_and_cancel_build' ERR
  
  user_exists=false
  getent passwd root >/dev/null 2>&1 && user_exists=true
  
  if $user_exists; then
  
    mkdir -p ~root/.ssh
  
    cat << EOF >> ~root/.ssh/authorized_keys
  ssh-rsa XYZ foreman-proxy.com
  EOF
  
    chmod 0700 ~root/.ssh
    chmod 0600 ~root/.ssh/authorized_keys
    chown -R root: ~root/.ssh
  
    # Restore SELinux context with restorecon, if it's available:
    command -v restorecon && restorecon -RvF ~root/.ssh || true
  
  else
    echo 'The remote_execution_ssh_user does not exist and remote_execution_create_user is not set to true.  remote_execution_ssh_keys snippet will not install keys'
  fi
  
  echo '#'
  echo '# Installing Insights client'
  echo '#'
  
  yum install -y insights-client
  insights-client --register
  
  if command -v subscription-manager &>/dev/null; then
    echo "Refreshing subscription data"
    subscription-manager refresh
  fi
  
  # Call home to exit build mode
  
  trap - ERR
  foreman_curl 'http://satellite.example.com/unattended/built?token=b91a860e-3a68-43f4-b345-95ca7ff41307'
  
  if [[ $? == 0 ]] ; then
    echo "Host [client-1.example.com] successfully configured."
  else
    echo "Host [client-1.example.com] successfully configured, but failed to set built status."
  fi
  
  subscription-manager facts --update
  
  exit 0
  ~~~

- Here is the same script from the admin user.

  ~~~
  # Rendered with following template parameters:
  # User: [admin]
  # Organization: [RedHat]
  # Location: [Pune]
  # Setup Insights: [false]
  # Setup remote execution: [false]
  # Setup remote execution pull: [false]
  # Update packages: [false]
  # Activation keys: [GENERAL]
  ~~~

  ~~~
  #!/bin/bash
  set -e
  
  echo "# Running [client-2.example.com] host initial configuration"
  
  foreman_curl() {
    curl --silent --show-error  -o /dev/null --noproxy \* "$@"
  }
  
  exit_and_cancel_build() {
    echo 'Host [client-2.example.com] initial configuration failed'
    foreman_curl --request POST 'http://satellite.example.com/unattended/failed?token=XYZ' \
         --data 'Host initial configuration failed, please see the registration log for more details.'
    exit 1
  }
  
  set +e
  trap 'exit_and_cancel_build' ERR
  
  if command -v subscription-manager &>/dev/null; then
    echo "Refreshing subscription data"
    subscription-manager refresh
  fi
  
  # Call home to exit build mode
  
  trap - ERR
  foreman_curl 'http://satellite.example.com/unattended/built?token=XYZ'
  
  if [[ $? == 0 ]] ; then
    echo "Host [client-2.example.com] successfully configured."
  else
    echo "Host [client-2.example.com] successfully configured, but failed to set built status."
  fi
  
  subscription-manager facts --update
  
  exit 0
  ~~~

  This excludes all the setups that are set to No.

Expected results:

- Script should not perform the setups that are set to No.

Comment 1 Leos Stejskal 2023-06-07 08:29:12 UTC
The issue is reproducible on the latest foreman develop, looking into the solution.

Comment 2 Leos Stejskal 2023-06-07 10:32:24 UTC
Created redmine issue https://projects.theforeman.org/issues/36484 from this bug

Comment 3 Bryan Kearney 2023-06-12 16:03:19 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36484 has been resolved.

Comment 4 Shweta Singh 2023-07-20 10:49:13 UTC
Verified.

Version Tested: Satellite 6.14 Snap 7.0

Verification Steps:
1. Enable the required repositories on the satellite and get a host(RHEL7/RHEL8/RHEL9)
2. Create a non-admin user and assign "Register Hosts" role to it.
3. Create an activation key and assign CV and LCE to it.
4. Login Satellite with new user and generate curl command to register host with all setup options set to NO.
5. Run the curl command on the host.

Result:
The script generated by this command skips the setups that are set to No.

Comment 7 errata-xmlrpc 2023-11-08 14:19:24 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 (Important: Satellite 6.14 security and bug fix update), 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-2023:6818


Note You need to log in before you can comment on or make changes to this bug.