Bug 1451503

Summary: Setting undercloud_hostname creates an invalid /etc/hosts file
Product: Red Hat OpenStack Reporter: Darin Sorrentino <dsorrent>
Component: instack-undercloudAssignee: James Slagle <jslagle>
Status: CLOSED ERRATA QA Contact: Gurenko Alex <agurenko>
Severity: medium Docs Contact:
Priority: medium    
Version: 10.0 (Newton)CC: ahrechan, aschultz, emacchi, mburns, rhel-osp-director-maint, tvignaud
Target Milestone: gaKeywords: Triaged
Target Release: 12.0 (Pike)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: instack-undercloud-7.4.1-1.el7ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-13 21:27:05 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:
Attachments:
Description Flags
undercloud_install.log none

Description Darin Sorrentino 2017-05-16 20:14:05 UTC
Description of problem:

If you set undercloud_hostname in the undercloud.conf, it results in a SECOND 127.0.0.1 entry in /etc/hosts.  Not only is this an invalid hosts file, it mucks up stuff like ansible_fqdn which then returns localhost.localdomain instead of the actual FQDN.

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

I noticed this in OSP10 but it may affect previous releases as well.

How reproducible:


Steps to Reproduce:
1. Set undercloud_hostname in undercloud.conf
2. Deploy
3. cat /etc/hosts

Actual results:

[root@darin-undercloud stack]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1 darin-undercloud.redhat.local darin-undercloud


Expected results:

[root@darin-undercloud stack]# cat /etc/hosts
127.0.0.1   darin-undercloud.redhat.local darin-undercloud localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


Additional info:

Comment 1 James Slagle 2017-05-16 22:18:12 UTC
the code should only added the extra line for the hostname if there isn't already a line for the hostname in /etc/hosts. It was a failsafe that was added since the step was often skipped/forgotten in the docs, and multiple services (particularly rabbitmq) are quite picky about the name being in /etc/hosts:

https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/10/html-single/director_installation_and_usage/#sect-Setting_the_Hostname_for_the_System

That being said, I didn't realize that technically that syntax with the same IP on multiple lines is invalid. You should be able to workaround the issue if you set it yourself though.

Comment 2 Darin Sorrentino 2017-05-18 20:19:23 UTC
Yes, I completely understand the reasoning behind adding the setting to undercloud.conf.  Just wanted to bug report it so it does eventually get fixed.

The manpage for /etc/hosts reads:

       This manual page describes the format of the /etc/hosts file.  This
       file is a simple text file that associates IP addresses with
       hostnames, one line per IP address.  For each host a single line
       should be present with the following information:

              IP_address canonical_hostname [aliases...]

Comment 6 Artem Hrechanychenko 2017-11-10 12:22:05 UTC
FailedQA

instack-undercloud-7.4.2-2.el7ost.noarch

[stack@undercloud-0 ~]$ cat undercloud.conf 
[DEFAULT]
# Network interface on the Undercloud that will be handling the PXE
# boots and DHCP for Overcloud instances. (string value)
local_interface = eth0
# 192.168.24.0 subnet is by default used since RHOS11
local_ip = 192.168.24.1/24
network_gateway = 192.168.24.1
undercloud_public_vip = 192.168.24.2
undercloud_admin_vip = 192.168.24.3
network_cidr = 192.168.24.0/24
masquerade_network = 192.168.24.0/24
dhcp_start = 192.168.24.5
dhcp_end = 192.168.24.24
inspection_iprange = 192.168.24.100,192.168.24.120
undercloud_hostname = test_for_bz.redhat.local

[stack@undercloud-0 ~]$ cat /etc/hosts
127.0.0.1   test_for_bz.redhat.local test_for_bz localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1   test_for_bz.redhat.local test_for_bz undercloud-0.redhat.local undercloud-0

[stack@undercloud-0 ~]$ hostname -f
test_for_bz.redhat.local


undercloud installation failed
undercloud_install.log in attachment

Comment 7 Artem Hrechanychenko 2017-11-10 12:23:03 UTC
FailedQA

Comment 8 Artem Hrechanychenko 2017-11-10 12:23:35 UTC
Created attachment 1350453 [details]
undercloud_install.log

Comment 9 Artem Hrechanychenko 2017-11-10 16:02:08 UTC
Moving to ON_QA because undercloud deployment failed even with without undercloud_hostname in undercloud.conf

Comment 13 errata-xmlrpc 2017-12-13 21:27:05 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/RHEA-2017:3462