Bug 1584776

Summary: katello-change-hostname should check current hostname to make sure that the hostname was not changed with a different tool
Product: Red Hat Satellite Reporter: Michal Dekan <mdekan>
Component: satellite-change-hostnameAssignee: John Mitsch <jomitsch>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.14CC: jomitsch, zhunting
Target Milestone: 6.4.0Keywords: Triaged, UserExperience
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: katello-3.7.0-5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-16 19:25:16 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:

Description Michal Dekan 2018-05-31 15:50:34 UTC
Description of problem:

This is to avoid bad tool usage as currently its possible to change the hostname with hostnamectl and then execute katello-change-hostname which leads to the error:

Error: smart_proxy not found
Couldn't find default Capsule id
Failed 'hammer -u admin -p changeme --output json capsule info --name old-hostname' with exit code 70


Version-Release number of selected component (if applicable):

Satellite 6.2.14
Satellite 6.2.15

How reproducible:

Change satellite hostname with hostnamectl and then run katello-change-hostname

Steps to Reproduce:

1. hostnameclt set-hostname katello.example.com
2. katello-change-hostname katello.example.com -u admin -p XXX (will fail with above)

Changing to the old hostname with hostnamectl so katello-change-hostname can pass:

3. hostnamectl set-hostname test2.example.com
4. katello-change-hostname katello.example.com -u admin -p XXX (will pass)

Mongo will contain old hostname:
5. > db.event_listeners.find()
{ "_id" : ObjectId("5b0ff0b0226fa42c34df85b1"), "notifier_config" : { "url" : "https://test2.example.com/katello/api/v2/repositories/sync_complete?token=....


Actual results:

katello-change-hostname will run when hostname was already changed with hostnamectl which produces error.

Expected results:

Add check to find out if new hostname used with katello-change-hostname is matching with current hostname from hostnamectl. It should not match, if it does it should error out and not proceed further.

Comment 2 John Mitsch 2018-07-27 13:58:22 UTC
Created redmine issue https://projects.theforeman.org/issues/24422 from this bug

Comment 3 Satellite Program 2018-07-27 14:25:16 UTC
Upstream bug assigned to jomitsch

Comment 4 Satellite Program 2018-07-27 14:25:18 UTC
Upstream bug assigned to jomitsch

Comment 5 Peter Ondrejka 2018-09-05 13:05:48 UTC
Verified with satellite 6.4 snap 20 

satellite-change-hostname ... -u admin -p xxx
The hostname specified must be different from the current hostname. If you have changed the hostname with another utility, please change it back to the original hostname before running this tool.

Comment 6 Bryan Kearney 2018-10-16 19:25:16 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/RHSA-2018:2927