From 19d4913c459aa59abde0a8c6ee92d8bd1e0fef8e Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 28 Mar 2017 10:28:08 +0100 Subject: [PATCH] Workaround for Bifrost being unable to write to /etc/hosts Bifrost cannot modify /etc/hosts from within a container, so add a host entry during bootstrap. Change-Id: Ied378b4dd755788e75ad1814cecb5700732ba83e Closes-Bug: #1661009 --- ansible/roles/bifrost/tasks/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ansible/roles/bifrost/tasks/config.yml b/ansible/roles/bifrost/tasks/config.yml index 6fbeb85a7f..11a59a6d3c 100644 --- a/ansible/roles/bifrost/tasks/config.yml +++ b/ansible/roles/bifrost/tasks/config.yml @@ -34,3 +34,16 @@ - { src: "id_rsa", dest: "id_rsa" } - { src: "id_rsa.pub", dest: "id_rsa.pub" } - { src: "ssh_config", dest: "ssh_config" } + +# NOTE(mgoddard): The following two tasks were lifted from the Bifrost plays. +# Because Bifrost cannot modify /etc/hosts from within the container we must +# do it here. +- name: "RabbitMQ - Testing if hostname is defined in /etc/hosts" + command: grep -i "{{ ansible_hostname }}" /etc/hosts + ignore_errors: yes + register: test_grep_fix_hostname + +- name: "RabbitMQ - Fixing /etc/hosts" + command: sed -i 's/localhost/{{ ansible_hostname }} localhost/' /etc/hosts + when: test_grep_fix_hostname.rc != 0 + become: True