Bug 1343585

Summary: Bootstrap script assumes that host's domain is created prior to running bootstrap.py.
Product: Red Hat Satellite Reporter: Lukas Pramuk <lpramuk>
Component: BootstrapAssignee: Rich Jerrido <rjerrido>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bbuckingham, bkearney, dmoessne, egolov, greartes, johan.bergstrom, sanichol, zhunting
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: katello-client-bootstrap-1.2.0-4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1394380 (view as bug list) Environment:
Last Closed: 2016-12-12 17:11:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1394380    

Description Lukas Pramuk 2016-06-07 13:55:01 UTC
Description of problem:
Bootstrap script assumes that host is in the same domain as Satellite is.
If it is not your case, then you have to pre-create host's domain in Satellite.

Version-Release number of selected component (if applicable):
@Sat6.2.0-Snap14
katello-client-bootstrap-1.1.0-1.el7sat.noarch

How reproducible:
always

Steps to Reproduce:
1. # ./bootstrap.py -l admin -p changeme -s <SAT_FQDN> -o 'Default Organization' -L 'Default Location' -g 'My Hostgroup' -a My_Activation_Key
Foreman Bootstrap Script
This script is designed to register new systems or to migrate an existing system to a Foreman server with Katello
[NOTIFICATION], [2016-06-06 08:47:27], [This system is not registered to RHN. Attempting to register via subscription-manager] 
[NOTIFICATION], [2016-06-06 08:47:27], [Retrieving Client CA Certificate RPMs] 
[RUNNING], [2016-06-06 08:47:27], [rpm -Uvh http://<SAT_FQDN>/pub/katello-ca-consumer-latest.noarch.rpm] 
Retrieving http://<SAT_FQDN>/pub/katello-ca-consumer-latest.noarch.rpm
Preparing...                ##################################################
katello-ca-consumer-<SAT_FQD##################################################
[SUCCESS], [2016-06-06 08:47:32], [rpm -Uvh http://<SAT_FQDN>/pub/katello-ca-consumer-latest.noarch.rpm], completed successfully.

[ERROR], [2016-06-06 08:47:33], EXITING: [0 element in array for search key 'name="<CLIENT_DOMAIN>"' in API '/api/v2/domains'. Please note that all searches are case-sensitive. Fatal error.] failed to execute properly.


Actual results:
Script expects a domain for host to be already present and a user has to guess that
It doesn't care of domain associated with hostgroup, it insists on deriving domain from host fqdn on its own.

Expected results:
Such behavior should be either re-implemented or documented

Comment 1 Evgeni Golov 2016-06-07 14:14:20 UTC
There is a PR upstream to solve this: https://github.com/Katello/katello-client-bootstrap/pull/85

Comment 3 Rich Jerrido 2016-06-07 17:14:19 UTC
The current $SUBJECT of this BZ is a bit inaccurate. current bootstrap assumes the domain of the host that is being registered exists prior to invocation of the script. On a Satellite with a single domain, these are the same, but may not always be the case. Updating $SUBJECT appropriately.

Comment 4 Bryan Kearney 2016-08-19 12:16:56 UTC
Upstream code is merged, moving to POST.

Comment 5 Lukas Pramuk 2016-12-05 14:27:11 UTC
VERIFIED.

@satellite-6.2.5-1.0.el6sat.noarch
katello-client-bootstrap-1.2.0-4.el6sat.noarch

# ./bootstrap.py -l admin -p changeme -s <SAT_FQDN> -o 'Default Organization' -L 'Default Location' -g 'My Hostgroup' -a 'My AK'
...
[NOTIFICATION], [2016-12-05 09:15:29], [Domain khw.example.com doesn't exist in Foreman, consider using the --add-domain option.] 


# ./bootstrap.py -l admin -p changeme -s <SAT_FQDN> -o 'Default Organization' -L 'Default Location' -g 'My Hostgroup' -a 'My AK' --add-domain
...
[RUNNING], [2016-12-05 09:19:10], [Calling Foreman API to create domain khw.example.com associated with the org & location] 
[RUNNING], [2016-12-05 09:19:10], [Calling Foreman API to create a host entry associated with the group & org] 
[SUCCESS], [2016-12-05 09:19:10], [Successfully created host host.khw.example.com], completed successfully.
...

>>> when a host has different domain than Satellite script offers to add '--add-domain' option

>>> with '--add-domain' option host is created successfully (and its domain too)

Comment 7 errata-xmlrpc 2016-12-12 17:11:39 UTC
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-2016:2940