Bug 1451503 - Setting undercloud_hostname creates an invalid /etc/hosts file
Summary: Setting undercloud_hostname creates an invalid /etc/hosts file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: instack-undercloud
Version: 10.0 (Newton)
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ga
: 12.0 (Pike)
Assignee: James Slagle
QA Contact: Gurenko Alex
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-16 20:14 UTC by Darin Sorrentino
Modified: 2018-02-05 19:07 UTC (History)
6 users (show)

Fixed In Version: instack-undercloud-7.4.1-1.el7ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-13 21:27:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
undercloud_install.log (246.78 KB, text/plain)
2017-11-10 12:23 UTC, Artem Hrechanychenko
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Launchpad 1709460 0 None None None 2017-08-08 19:54:27 UTC
OpenStack gerrit 510664 0 'None' MERGED Fix invalid /etc/hosts edit 2020-08-05 05:44:50 UTC
Red Hat Product Errata RHEA-2017:3462 0 normal SHIPPED_LIVE Red Hat OpenStack Platform 12.0 Enhancement Advisory 2018-02-16 01:43:25 UTC

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


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