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
This commit is contained in:
Major Hayden 2016-07-25 16:00:41 -05:00
parent ad1630f693
commit bb1fd16c75

View File

@ -44,14 +44,20 @@
lineinfile: lineinfile:
dest: /etc/hosts dest: /etc/hosts
state: present state: present
line: > line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}"
{{ hostvars[item]['ansible_ssh_host'] }}
{{ hostvars[item]['ansible_hostname'] }}
{% if hostvars[item]['ansible_hostname'] != 'localhost' %}{{ hostvars[item]['ansible_hostname'].split('.')[0] }}{% endif %}
with_items: "{{ groups[rabbitmq_host_group] }}" with_items: "{{ groups[rabbitmq_host_group] }}"
tags: tags:
- rabbitmq-config - 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 - name: Create the local directories
file: file:
path: "/etc/rabbitmq/" path: "/etc/rabbitmq/"