Remove extra whitespaces from getent.

The UndercloudHostsEntries heat parameter gets its value set from the
execution of getent hosts <undercloud_short_hostname>.ctrlplane. However,
the execution of getent return extra 4 whitespaces between the IP and the
hostname:
(undercloud) [stack@undercloud-0 ~]$ getent hosts undercloud-0.ctlplane
192.168.24.1    undercloud-0.ctlplane.redhat.local undercloud-0.ctlplane

This four spaces enter in conflict with the entries at /etc/hosts if we
want to use lineinfile to update the content. As it /ect/hosts already
includes an entry for the undercloud-0.ctlplane (with a single space only)
the Ansible module will consider that the line isn't present and we will
end up with two entries for the undercloud-0.ctlplane.

Also, the process.communicate() output return is in bytes, so in order
to handle a string for the replacement this patch casts the output into
string.

Change-Id: Ibb51d5970f993b13a9684173704f64b98d81aae2
Related-Bug: #1863598
(cherry picked from commit 70d9d309ce)
This commit is contained in:
Jose Luis Franco Arza 2020-02-17 14:50:00 +01:00 committed by Jose Luis Franco
parent eefe92ee64
commit 5e40c70793
1 changed files with 1 additions and 1 deletions

View File

@ -128,7 +128,7 @@ class DeployOvercloud(command.Command):
raise exceptions.DeploymentError('No entry for %s in /etc/hosts'
% ctlplane_hostname)
return out.rstrip()
return re.sub(' +', ' ', str(out).rstrip())
def _create_breakpoint_cleanup_env(self, tht_root, container_name):
bp_env = {}