Write localhost line in /etc/hosts when testing

In the test builds, localhost is in the inventory and the /etc/hosts
line isn't adjusted properly since the hostname won't split on a
period.

This patch allows the localhost line in /etc/hosts to be
managed properly during testing builds. This affects CentOS
builds intermittently.

Change-Id: I6368b6584265084af6ff98caba68fc067b1f1f22
This commit is contained in:
Major Hayden 2016-07-22 20:22:38 -05:00
parent 871a07b75d
commit 67360bb892

View File

@ -44,7 +44,10 @@
lineinfile:
dest: /etc/hosts
state: present
line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}"
line: >
{{ 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] }}"
tags:
- rabbitmq-config