From 53a3844bc4cf0b23a630e3b0f58d4a7af6c20ed3 Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Fri, 29 Aug 2014 15:31:58 +0100 Subject: [PATCH] Fix /etc/hosts issues on rabbit servers when using FQDN Rabbit occassionally fails to start because it can't resolve its "short name" The /etc/hosts file is dropped after the install phase, which starts up rabbit automatically - Moving the /etc/hosts file correction to happen before the install phase will resolve this. Fixes #39 --- .../roles/rabbit_common/tasks/main.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rpc_deployment/roles/rabbit_common/tasks/main.yml b/rpc_deployment/roles/rabbit_common/tasks/main.yml index 13259455a9..d17e614047 100644 --- a/rpc_deployment/roles/rabbit_common/tasks/main.yml +++ b/rpc_deployment/roles/rabbit_common/tasks/main.yml @@ -31,6 +31,16 @@ - package_install - rabbit_install +- name: Fix /etc/hosts + lineinfile: + dest: /etc/hosts + state: present + line: "{{ hostvars[item]['container_address'] }} {{ hostvars[item]['container_name'] }} {{ hostvars[item]['container_name'].split('.')[0] }}" + with_items: groups['rabbit'] + tags: + - hosts + - rabbit_config + - name: Install rabbit packages apt: pkg: "{{ item }}" @@ -43,16 +53,6 @@ - package_install - rabbit_install -- name: Fix /etc/hosts - lineinfile: - dest: /etc/hosts - state: present - line: "{{ hostvars[item]['container_address'] }} {{ hostvars[item]['container_name'] }} {{ hostvars[item]['container_name'].split('.')[0] }}" - with_items: groups['rabbit'] - tags: - - hosts - - rabbit_config - - include: restart_rabbit.yml - name: Read rabbit cookie