Bug 1451503 - Setting undercloud_hostname creates an invalid /etc/hosts file
Summary: Setting undercloud_hostname creates an invalid /etc/hosts file
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: instack-undercloud
Version: 10.0 (Newton)
Hardware: Unspecified
OS: Unspecified
Target Milestone: ga
: 12.0 (Pike)
Assignee: James Slagle
QA Contact: Gurenko Alex
Depends On:
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:
Last Closed: 2017-12-13 21:27:05 UTC
Target Upstream Version:

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

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 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   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 darin-undercloud.redhat.local darin-undercloud

Expected results:

[root@darin-undercloud stack]# cat /etc/hosts   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:


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


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

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

[stack@undercloud-0 ~]$ hostname -f

undercloud installation failed
undercloud_install.log in attachment

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

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

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.


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