Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1426424 - Bootstrap fails to register systems with invalid hostnames or only have short names
Bootstrap fails to register systems with invalid hostnames or only have short...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Bootstrap (Show other bugs)
6.2.8
Unspecified Unspecified
high Severity high (vote)
: GA
: Unused
Assigned To: Rich Jerrido
Lukáš Hellebrandt
: Triaged
Depends On: 1425606
Blocks: 1122832
  Show dependency treegraph
 
Reported: 2017-02-23 15:49 EST by pm-sat@redhat.com
Modified: 2018-11-02 09:16 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1425606
Environment:
Last Closed: 2018-02-21 12:06:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description pm-sat@redhat.com 2017-02-23 15:49:20 EST
+++ This bug was initially created as a clone of Bug #1425606 +++

Description of problem:

When running bootstrap, it fails to register a system that has an invalid hostname, (such as one with an underscore), or hostname that are short (hostname -f) doesn't return an FQDN, 


Version-Release number of selected component (if applicable):
katello-client-bootstrap-1.2.2

How reproducible:
100%

Steps to Reproduce:
1. Create a system with a 

short name (where hostname -f or "ython -c "import socket;print socket.getfqdn()"" returns a shortname

or an invalid name. (Such as a name with an underscore), such as foo_bar.example.com


2. Register with bootstrap. 
3.

Actual results:
bootstrap fails with an error similar to the following:

    [RUNNING], [2017-02-21 14:13:01], [Calling Foreman API to create a host entry associated with the group, domain, org & location]
    url: https://<capsule-fqdn>:8443/api/v2/hosts/
    method: POST
    data: {
      "host": {
        "managed": "true",
        "name": "<hostname>",
        "hostgroup_id": 22,
        "organization_id": 1,
        "mac": "00:50:56:90:11:D2",
        "architecture_id": 1,
        "location_id": 3,
        "domain_id": 6
      }
    }
    Error: The following error occured while talking to the API:
    url: https://<capsule-fqdn>:8443/api/v2/hosts/
    code: 422
    data: {
      "host": {
        "managed": "true",
        "name": "<hostname>",
        "hostgroup_id": 22,
        "organization_id": 1,
        "mac": "00:50:56:90:11:D2",
        "architecture_id": 1,
        "location_id": 3,
        "domain_id": 6
      }
    }
    error: {
      "error": {
        "errors": {
          "interfaces.name": [
            "is invalid"
          ],
          "name": [
            "is invalid"
          ]
        },
        "id": null,
        "full_messages": [
          "Name is invalid",
          "Name is invalid"
        ]
      }
    }

Expected results:

bootstrap successfully registers the system. 

Additional info:

--- Additional comment from rjerrido@redhat.com on 20170221T22:23:22

Also RFC 952 or 1123 covers hostname validation and Foreman appears to respect this (see lib/net/validations.rb). 

As we generally cannot ask the customer to change their hostnames (many have short names for 3rd party apps), it might be advisable to allow the customer to set an arbitrary hostname in bootstrap.py (for puppet and subscription-manager) that differs from what the system reports.

--- Additional comment from rjerrido@redhat.com on 20170223T19:29:43

Fixed in commit https://github.com/Katello/katello-client-bootstrap/commit/49ec1ae44a7463f5f615ad6d59fccd21d9da6bda
Comment 3 Lukáš Hellebrandt 2017-10-17 10:34:29 EDT
Verified with Sat6.3 snap 20.

Used reproducer from original BZ's comment 4:

# ./bootstrap.py -s <Satellite_FQDN> -o 'Default Organization' -a testak -g 'testhostgroup' -L 'Default Location' --fqdn <client_FQDN>

Note: When run without the --fqdn parameter, the following error text is shown:

"""
We could not determine the domain of this machine, most probably `hostname -f` does not return the FQDN.
This can lead to Puppet missbehaviour and thus the script will terminate now.
You can override this by passing one of the following
	--force - to disable all checking
	--skip-puppet - to omit installing the puppet agent
"""

As we solved this by using --fqdn parameter, this should also be mentioned in the error text.
Comment 4 Bryan Kearney 2018-02-21 12:06:49 EST
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/RHSA-2018:0336

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