Host registration with the Red Hat Satellite server failing with error: Validation failed: Name has already been taken.

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.x

Issue

  • Host registration with the Red Hat Satellite server failing with below error:

    # subscription-manager register --org="Redhat" --activationkey="<AK1>"
    HTTP error (422 - Unknown): Validation failed: Name has already been taken
    

Resolution

SOLUTION 1

  • Check if the puppet-agent was configured on the client and the stale entry is still available under /etc/puppetlabs/puppet/ssl.
  • If the stale entry is still available then clear the old certs from /etc/puppetlabs/puppet/ssl and try to re-register the client.

SOLUTION 2


NOTE: Please ensure Satellite Backup/Snapshot before executing below commands:
  • STEP 1: Run the below commands on the problematic host.

      subscription-manager remove --all
      subscription-manager unregister
      subscription-manager clean
    
  • STEP 2: Check All Hosts and Content Hosts for client1.example.com, check if the host is present in Any Organization and Any Location. If the host doesn't appear, goto STEP 3.

  • STEP 3: Access the foreman database and search for the hostname with the below query and note down the name,id and type set for the host entry if there any.

      # su - postgres -c 'psql foreman -c "select id,name,type from hosts where name = '\''host.example.com'\'';"'
      # su - postgres -c 'psql foreman -c "select id,name,type from hosts where name like '\''%host.example.com%'\'';"'
    
  • STEP 4: With the host id and name collected, executed the following steps to delete the record of the host and it's related entries from database properly.

      // Go inside rake console
    
      #  foreman-rake console
    
    
      // Now look for the Host by it's ID or name [ Considering name is host.example.com and id is X ]
    
      > hb = Host::Base.find_by_name('host.example.com')
    
      or
    
      > hb = Host::Base.find(X)
    
    
      // Find out if the type is set as Host::Managed or not . If not, Set it as "Host:: Managed"
    
      > hb.type                                    ## To Check
    
      > hb.update_column(:type, "Host::Managed")   ## To Set
    
      > hb.type                                    ## To Check and confirm
      
    
      // Start deletion of the host now
    
      > h = Host.find_by_id(X)                     ## This should show some details of the host
    
      > h.disassociate!
    
      > HostStatus::Status.where(host_id: h.id).delete_all
    
      > h.subscription_facet.destroy if h.subscription_facet
    
      > h.content_facet.destroy if h.content_facet
    
      > h.registration_facet.destroy if h.registration_facet
    
      > h.destroy
    
      
      // Verify if the host is deleted for good
    
      > Host.find_by_id(X)
    
      // Exit from the console
    
      > exit
    
  • STEP 5: Proceed with the registration of the host now.

For more KB articles/solutions related to Red Hat Satellite 6.x Client Host Registration Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Host Registration Issues

Root Cause

  • The puppet-agent was configured on the host before and the old certs were still available in /etc/puppetlabs/puppet/ssl path.

  • A bad attempt of rebuild or deletion of the host caused the reference of the host to remain in some of the tables of the foreman database but no visible entries of the host in Satellite UI.

SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.