aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-10-11 18:08:35 +0000
committerGerrit Code Review <review@openstack.org>2019-10-11 18:08:35 +0000
commit9e18c8fc690a4a63e488c71a5e25feee1174e32d (patch)
treedd885eddf27fc38ec50eaa81a167aa62d5ae68aa
parente08f046dafa7a357d5d662c78309342115e28732 (diff)
parent0b24a0f2f0880c35368581e3acc529672da665f8 (diff)
downloadkolla-ansible-9e18c8fc690a4a63e488c71a5e25feee1174e32d.tar.gz
kolla-ansible-9e18c8fc690a4a63e488c71a5e25feee1174e32d.zip
Merge "Remove /etc/hosts entries pointing hostname to localhost and prevent cloud-init to manage /etc/hosts"
-rw-r--r--ansible/roles/baremetal/tasks/pre-install.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml
index f29b62ea2..61387beb7 100644
--- a/ansible/roles/baremetal/tasks/pre-install.yml
+++ b/ansible/roles/baremetal/tasks/pre-install.yml
@@ -16,6 +16,18 @@
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
+# 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
+ lineinfile:
+ dest: /etc/hosts
+ regexp: "^127.\\d+.\\d+.\\d+(\\s+{{ ansible_nodename }})?\\s+{{ ansible_hostname }}$"
+ state: absent
+ become: True
+ when: customize_etc_hosts | bool
+
- name: Generate /etc/hosts for all of the nodes
blockinfile:
dest: /etc/hosts
@@ -35,6 +47,26 @@
- inventory_hostname not in groups['bifrost'] or
'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname]
+# NOTE(osmanlicilegi): The distribution might come with cloud-init installed, and manage_etc_hosts
+# configuration enabled. If so, it will override the file /etc/hosts from cloud-init templates at
+# every boot, which will break RabbitMQ. To prevent this happens, first we check whether cloud-init
+# has been installed, and then set manage_etc_hosts to false.
+- name: Check whether cloud-init has been installed, and ensure manage_etc_hosts is disabled
+ block:
+ - name: Ensure /etc/cloud/cloud.cfg exists
+ stat:
+ path: /etc/cloud/cloud.cfg
+ register: cloud_init
+
+ - name: Disable cloud-init manage_etc_hosts
+ copy:
+ content: "manage_etc_hosts: false"
+ dest: /etc/cloud/cloud.cfg.d/99-kolla.cfg
+ mode: "0660"
+ when: cloud_init.stat.exists
+ become: True
+ when: customize_etc_hosts | bool
+
- name: Ensure sudo group is present
group:
name: sudo