From ddc564d21f0fcabde3795a7d496b249133b36684 Mon Sep 17 00:00:00 2001
From: MinSun <minsu@cisco.com>
Date: Fri, 1 Jun 2018 10:22:23 +0800
Subject: [PATCH] Rabbitmq bootstrap enhancement

Using rabbitmq service defined in default when
boot rabbitmq_bootstrap.
Not a bug here, just an enhancement.

Change-Id: I79f0f7efe3308ed4eb898b85a6370be1bd637d9a
---
 ansible/roles/rabbitmq/defaults/main.yml   |  5 +++++
 ansible/roles/rabbitmq/tasks/bootstrap.yml | 16 ++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/ansible/roles/rabbitmq/defaults/main.yml b/ansible/roles/rabbitmq/defaults/main.yml
index a8e1fadf20..deb7876f7a 100644
--- a/ansible/roles/rabbitmq/defaults/main.yml
+++ b/ansible/roles/rabbitmq/defaults/main.yml
@@ -7,6 +7,11 @@ rabbitmq_services:
     group: "{{ role_rabbitmq_groups }}"
     enabled: true
     image: "{{ rabbitmq_image_full }}"
+    bootstrap_environment:
+      KOLLA_BOOTSTRAP:
+      KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+      RABBITMQ_CLUSTER_COOKIE: "{{ role_rabbitmq_cluster_cookie }}"
+      RABBITMQ_LOG_DIR: "/var/log/kolla/{{ project_name }}"
     environment:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
       RABBITMQ_CLUSTER_COOKIE: "{{ role_rabbitmq_cluster_cookie }}"
diff --git a/ansible/roles/rabbitmq/tasks/bootstrap.yml b/ansible/roles/rabbitmq/tasks/bootstrap.yml
index 7a79f926d2..10dd5f721c 100644
--- a/ansible/roles/rabbitmq/tasks/bootstrap.yml
+++ b/ansible/roles/rabbitmq/tasks/bootstrap.yml
@@ -7,22 +7,18 @@
   register: rabbitmq_volume
 
 - name: Running RabbitMQ bootstrap container
+  vars:
+    service_name: "rabbitmq"
+    service: "{{ rabbitmq_services[service_name] }}"
   kolla_docker:
     action: "start_container"
     common_options: "{{ docker_common_options }}"
     detach: False
-    environment:
-      KOLLA_BOOTSTRAP:
-      KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
-      RABBITMQ_CLUSTER_COOKIE: "{{ role_rabbitmq_cluster_cookie }}"
-      RABBITMQ_LOG_DIR: "/var/log/kolla/{{ project_name }}"
-    image: "{{ rabbitmq_image_full }}"
+    environment: "{{ service.bootstrap_environment }}"
+    image: "{{ service.image }}"
     labels:
       BOOTSTRAP:
     name: "{{ project_name }}_bootstrap"
     restart_policy: "never"
-    volumes:
-      - "{{ node_config_directory }}/{{ project_name }}/:{{ container_config_directory }}/:ro"
-      - "/etc/localtime:/etc/localtime:ro"
-      - "{{ project_name }}:/var/lib/rabbitmq/"
+    volumes: "{{ service.volumes }}"
   when: rabbitmq_volume | changed