Hide Forgot
Description of problem: On Satellite 6.2.5 we should enforce FQDN when registering a system. To accomplish that, it was introduced a new step on the boostrap process to save the override the FQDN by creating the file /etc/rhsm/facts/katello.facts. # tail /usr/bin/katello-rhsm-consumer -n 7 | grep -v ^# | grep -v ^$ if [ -d /etc/rhsm/facts/ ]; then echo "{\"network.hostname-override\":\"`hostname -f`\"}" > /etc/rhsm/facts/katello.facts fi exit 0 The problem happens because the `hostname -f` will **FAIL** if there is no PTR entry on the DNS or any entry in /etc/hosts file. # hostname -f hostname: Unknown host Thus, the file will be created as follow: # cat /etc/rhsm/facts/katello.facts {"network.hostname-override":""} When trying to register it, Satellite will error out with the error below: # subscription-manager register --org="Default_Organization" --environment="Library" Registering to: sat6mmello.usersys.redhat.com:443/rhsm Username: admin Password: Validation failed: Name can't be blank, Name is invalid # cat /var/log/rhsm/rhsm.log 2016-12-16 15:21:30,151 [ERROR] subscription-manager:30740 @managercli.py:1108 - Validation failed: Name can't be blank, Name is invalid Traceback (most recent call last): File "/usr/share/rhsm/subscription_manager/managercli.py", line 1103, in _do_command content_tags=self.installed_mgr.tags) File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 913, in registerConsumer return self.conn.request_post(url, params) File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 684, in request_post return self._request("POST", method, params) File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 598, in _request self.validateResponse(result, request_type, handler) File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 648, in validateResponse raise RestlibException(response['status'], error_msg, response.get('headers')) RestlibException: Validation failed: Name can't be blank, Name is invalid ==> /var/log/foreman/production.log <== 2016-12-16 12:31:54 [foreman-tasks/action] [E] Validation failed: Name can't be blank, Name is invalid (ActiveRecord::RecordInvalid) | /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/validations.rb:57:in `save!' Version-Release number of selected component (if applicable): Red Hat Satellite 6.2.5 How reproducible: 100% Steps to Reproduce: 1. Install a system 2. Set a hostname that does not have a PTR entry or not in /etc/hosts 3. The command `hostname -f` should fail Actual results: Registering a system should fail Expected results: The /etc/rhsm/facts/katello.facts should only be created if hostname -f works. HOSTNAME=`hostname -f` IS_FQDN=`echo $?` if [ -d /etc/rhsm/facts/ ] && [ $IS_FQDN -eq 0 ]; then echo "{\"network.hostname-override\":\"$HOSTNAME\"}" > /etc/rhsm/facts/katello.facts fi
Connecting redmine issue http://projects.theforeman.org/issues/17721 from this bug
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17721 has been resolved.
so, the fix is introducing another problem. The override is in fact now overriding my fqdn. The katello.facts file being static is not a good idea. I spent hours trying to figure out why all of my hostname settings were not being reflected during registration.
I agree that caching the hostname in a static file is a bad idea. I've run in to the issue where "hostname -f" fails and an empty string is cached in the file, but I've also recently run in to an issue where a registered RHEL VM is cloned, and when you change the hostname and IP, reboot, and try to re-register the new system, it just overwrites the registration in Satellite of the original VM because it's still using the original VM's cached hostname. I don't see how there is any sense is caching the hostname in a separate file when it's available easily in the HOSTNAME environment variable or the "hostname" command for any applications running on the system.
Its a temporary measure to work around differences in how puppet and subscription-manager report the hostname. It is obsoleted by: https://bugzilla.redhat.com/show_bug.cgi?id=1367126 and by installing the newest katello-agent (which will provide the fqdn fact if its not present).
VERIFIED. @satellite-6.2.8-1.0.el7sat.noarch (snap3) katello-installer-base-3.0.0.77-1.el7sat.noarch tfm-rubygem-katello-3.0.0.103-1.el7sat.noarch by following manual reproducer: 1. Create a VM that SAT (6.2.7) is not aware of (preferably behind NAT) 2. Simulate that `hostname -f` fails for on the VM # cat > /usr/bin/hostname <<<'exit 1' 3. Install CA consumer certs # rpm -Uvh http://$SAT/pub/katello-ca-consumer-latest.noarch.rpm 4. Check contents of /etc/rhsm/facts/katello.facts # cat /etc/rhsm/facts/katello.facts {"network.hostname-override":""} 5. Try to register to 6.2.7 # subscription-manager register --force --username admin --password changeme Registering to: <SATFQDN>:443/rhsm Validation failed: Name can't be blank, Name is invalid >>> REPRODUCED 6. Upgrade SAT to 6.2.8 7. Check contents of /etc/rhsm/facts/katello.facts # cat /etc/rhsm/facts/katello.facts {"network.hostname-override":""} 8. Register to 6.2.8 # subscription-manager register --force --username admin --password changeme Registering to: <SATFQDN>:443/rhsm The system has been registered with ID: f4c33c48-34a2-4b0b-8df4-05a3a0e8b4e4 >>> VERIFIED that though network.hostname-override is empty the VM registers >>> re-registration of already (before the fix) registered client succeeds 9. Simulate brand new registration # subscription-manager unregister # rpm -e $(rpm -qa katello-ca-consumer-*) # rm -f /etc/rhsm/facts/katello.facts 10. Install CA consumer certs # rpm -Uvh http://$SAT/pub/katello-ca-consumer-latest.noarch.rpm 11. Check contents of /etc/rhsm/facts/katello.facts # cat /etc/rhsm/facts/katello.facts cat: /etc/rhsm/facts/katello.facts: No such file or directory 12. Register new (not yet registered) client # subscription-manager register --force --username admin --password changeme Registering to: <SATFQDN>:443/rhsm The system has been registered with ID: 094873f8-3972-4879-9452-fc8af730ea11 >>> VERIFIED that though /etc/rhsm/facts/katello.facts is no longer generated by /usr/bin/katello-rhsm-consumer the VM registers >>> the new client registration succeeds
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, 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/RHBA-2017:0447
This is good information as we hit this with virt-customize on a minimal kickstart image.