From bb1fd16c75657f91f4a3f3e1178142a67045eb3c Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Mon, 25 Jul 2016 16:00:41 -0500 Subject: [PATCH] Really fix localhost line in /etc/hosts This patch ensures that the localhost line in /etc/hosts is configured properly prior to installing and configuring RabbitMQ. Without this patch, the RabbitMQ installation often fails on CentOS 7 since RabbitMQ can't figure out its hostname. The fix in I6368b6584265084af6ff98caba68fc067b1f1f22 is reverted here because it had no effect on the /etc/hosts file. Change-Id: Ie65e5b7bcbaa1890824a93263c64e6fd04702852 --- tasks/rabbitmq_pre_install.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks/rabbitmq_pre_install.yml b/tasks/rabbitmq_pre_install.yml index 96cc4f0e..a2431e6e 100644 --- a/tasks/rabbitmq_pre_install.yml +++ b/tasks/rabbitmq_pre_install.yml @@ -44,14 +44,20 @@ lineinfile: dest: /etc/hosts state: present - line: > - {{ hostvars[item]['ansible_ssh_host'] }} - {{ hostvars[item]['ansible_hostname'] }} - {% if hostvars[item]['ansible_hostname'] != 'localhost' %}{{ hostvars[item]['ansible_hostname'].split('.')[0] }}{% endif %} + line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}" with_items: "{{ groups[rabbitmq_host_group] }}" tags: - rabbitmq-config +- name: Ensure localhost /etc/hosts entry is correct + lineinfile: + dest: /etc/hosts + state: present + line: '127.0.0.1 localhost' + regexp: '^127.0.0.1' + tags: + - rabbitmq-config + - name: Create the local directories file: path: "/etc/rabbitmq/"