Red Hat Satellite 6 failed with error that "change from 'absent' to 'present' failed: Host satellite.example.com does not exist in Foreman"

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.11

Issue

  • Receiving below error while performing an upgrade of the Red Hat Satellite 6.

    2022-07-13 10:25:54 [ERROR ] [configure] /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy_host[foreman-proxy-satellite.example.com]/ensure: change from 'absent' to 'present' failed: Host satellite.example.com does not exist in Foreman at https://satellite.example.com/
    

Resolution

  • Ensure that the following settings are set to true for the concerned satellite server.

    # hammer --csv settings list --fields "Name,Full name,Value" | egrep "append_domain_name_for_hosts|create_new_host|^Name" | column -s, -t
    Name                                     Full name                                Value
    append_domain_name_for_hosts             Append domain names to the host          true
    create_new_host_when_facts_are_uploaded  Create new host when facts are uploaded  true
    create_new_host_when_report_is_uploaded  Create new host when report is uploaded  true
    
  • Ensure the following:

    • The hostname -f command is showing the full FQDN of the Satellite server.
    • The hostname or hostname -s command is showing either the full FQDN or the short hostname ( without the domain ) of the satellite server.
    • The file /etc/foreman-installer/scenarios.d/satellite-answers.yaml contains the full FQDN as the value of different fields ( specifically the servername field ) but not the short hostname.
  • Identify if there are host records present in the foreman database for the FQDN or the short-hostname of the satellite server or by id 1.

    ( Assuming satellite.example.com is the FQDN and satellite is the short hostname )

    # echo "select id,name,type from hosts where name ilike '%satellite%' or id = 1;" | su - postgres -c "psql foreman"
    
    • If the command above prints no records at all, Then refer to the following solution article to get back the missing entry.

    • If the command above prints one record with short hostname mentioned, Then note down the ID of the Host profile from the output. Let's assume it's '1' and

      • Either, simply rename the profile in the database i.e.

        # echo "UPDATE hosts SET name = 'satellite.example.com' WHERE id = 1;" | su - postgres -c "psql foreman"
        
      • Or, Delete and re-create the entry i.e.

        ### Deletion
        
        # hammer host delete --id 1
        
        or,
        
        # cat << EOF | foreman-rake console
        Host.find_by_id(1).destroy!
        EOF
        
        
        ### Re-create
        
        # puppet-agent -tv
        
        or,
        
        # satellite-installer --verbose
        
  • Note: This feature of append_domain_name_for_hosts has been deprecated in Red Hat Satellite 6.12
    onwards and has been removed in Red Hat Satellite 6.15

 

Reach out to This content is not included.Red Hat Technical Support in case of any further assistance or clarification will be required.

For more KB articles/solutions related to Red Hat Satellite 6.x Installation/Upgrade/Update Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Installation/Upgrade/Update Issues.

Root Cause

While the satellite-installer is always expecting the host record with FQDN ( Fully Qualified Domain Name ) of the server one or a combination of the following conditions resulted in the entry being created with short hostname.

  • Satellite hostname is defined in shortname.

  • The record of satellite-related host profile is present with shortname in database as the append_domain_name_for_hosts setting is turned off\set to false.

Diagnostic Steps

  • Verify hostname on the server:

       # hostname
    
       # hostname -f
    
  • Verify Satellite Hostname entry in Host List by searching with FQDN and Shortname:

       # hammer host list --search "name = $(hostname)"
    
       # hammer host list --search "name = satellite-hostname"
    

    Note: Replace "satellite-hostname" with actual hostname of satellite server

  • Check /var/log/foreman/production.log to see if entries related to facts-upload are present in the logs or not.

    2022-12-08T14:46:01 [I|app|77357af8] Started POST "/api/hosts/facts" for X.X.X.X at 2022-12-08 14:46:01 +0800
    2022-12-08T14:46:01 [I|app|77357af8] Processing by Api::V2::HostsController#facts as JSON
    2022-12-08T14:46:01 [I|app|77357af8]   Parameters: {"facts"=>"[FILTERED]", "name"=>"satellite.example.com", "certname"=>"satellite.example.com", "apiv"=>"v2", "host"=>{"certname"=>"satellite.example.com", "name"=>"satellite.example.com"}}
    2022-12-08T14:46:01 [I|app|77357af8] Import facts for 'satellite' completed. Added: 2, Updated: 27, Deleted 32 facts
    2022-12-08T14:46:01 [I|app|77357af8] Completed 201 Created in 379ms (Views: 12.1ms | ActiveRecord: 72.9ms | Allocations: 71549)
    

    As it's visible, the facts were imported but for the host profile that is present with short hostname satellite.

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.