From adbe115e39ef2320e2e1ab57f97d5191282951d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Wed, 12 Feb 2020 12:08:28 +0100 Subject: [PATCH] Use more permissive regex to remove the offending 127.0.1.1 line from /etc/hosts Ubuntu always uses 127.0.1.1 for that with some tricky sauce around `hostname` depending on whether it contains '.' or not. And when I mean `hostname` it's the one returned by `hostname` command with no arguments. ansible_hostname is always a single word so we can match on that. I did not want to remove just any 127.0.1.1 in case someone is using it for other purposes. :-) Change-Id: I8bd3d42a5e3bd0f63336ed60a0af90d52b1650d6 Closes-bug: #1862739 --- ansible/roles/baremetal/tasks/pre-install.yml | 12 +++++++----- releasenotes/notes/bug-1862739-05246e7599375800.yaml | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/bug-1862739-05246e7599375800.yaml diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml index f13d7c8f7a..44c8b1692f 100644 --- a/ansible/roles/baremetal/tasks/pre-install.yml +++ b/ansible/roles/baremetal/tasks/pre-install.yml @@ -8,14 +8,16 @@ become: True when: customize_etc_hosts | bool -# NOTE(mgoddard): Ubuntu includes a line in /etc/hosts that makes the local -# hostname and nodename (if different) point to 127.0.1.1. This can break +# NOTE(mgoddard): Ubuntu may include a line in /etc/hosts that makes the local +# hostname and fqdn point to 127.0.1.1. This can break # RabbitMQ, which expects the hostname to resolve to the API network address. -# Remove these troublesome entries. -- name: Ensure hostname does not point to loopback in /etc/hosts +# Remove the troublesome entry. +# see https://bugs.launchpad.net/kolla-ansible/+bug/1837699 +# and https://bugs.launchpad.net/kolla-ansible/+bug/1862739 +- name: Ensure hostname does not point to 127.0.1.1 in /etc/hosts lineinfile: dest: /etc/hosts - regexp: "^127.\\d+.\\d+.\\d+(\\s+{{ ansible_nodename }})?\\s+{{ ansible_hostname }}$" + regexp: "^127.0.1.1\\b.*\\s{{ ansible_hostname }}\\b" state: absent become: True when: customize_etc_hosts | bool diff --git a/releasenotes/notes/bug-1862739-05246e7599375800.yaml b/releasenotes/notes/bug-1862739-05246e7599375800.yaml new file mode 100644 index 0000000000..fe466b3154 --- /dev/null +++ b/releasenotes/notes/bug-1862739-05246e7599375800.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Use more permissive regex to remove the offending 127.0.1.1 line + from /etc/hosts. + `LP#1862739 + `__