Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-18127

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

XMLWordPrintable

    • 0
    • False
    • Moderate
    • Rocket Sprint 9
    • None
    • None
    • None
    • None

      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.

      ~~~

      1. Rendered with following template parameters:
      2. User: [reg-user]
      3. Organization: [RedHat]
      4. Location: [Pune]
      5. Setup Insights: [false]
      6. Setup remote execution: [false]
      7. Setup remote execution pull: [false]
      8. Update packages: [false]
      9. 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@satellite.example.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

      1. 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.

              sat-lstejska Leos Stejskal (Inactive)
              jira-bugzilla-migration RH Bugzilla Integration
              Shweta Singh Shweta Singh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: