From 64a767db4d1b27c67b12163aadc44900e4898391 Mon Sep 17 00:00:00 2001 From: SamYaple Date: Fri, 29 Jan 2016 16:21:54 +0000 Subject: [PATCH] Convert rabbitmq to named volume Change-Id: I81413ffcaa4efb881d13fef62823d60b676e871d Implements: blueprint docker-named-volumes --- ansible/roles/rabbitmq/tasks/bootstrap.yml | 24 ++++++++-------------- ansible/roles/rabbitmq/tasks/start.yml | 5 +++-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/ansible/roles/rabbitmq/tasks/bootstrap.yml b/ansible/roles/rabbitmq/tasks/bootstrap.yml index c0f8343753..881d19553d 100644 --- a/ansible/roles/rabbitmq/tasks/bootstrap.yml +++ b/ansible/roles/rabbitmq/tasks/bootstrap.yml @@ -1,19 +1,10 @@ --- -# TODO(SamYaple): Improve check with a custom docker module to check if alive -- name: Checking if a rabbitmq_data exists - command: docker exec rabbitmq_data stat /var/lib/rabbitmq/.erlang.cookie - register: exists - changed_when: False - failed_when: False - always_run: True - -- name: Starting rabbitmq-data container +- name: Creating rabbitmq volume kolla_docker: - action: "start_container" + action: "create_volume" common_options: "{{ docker_common_options }}" - image: "{{ rabbitmq_data_image_full }}" - name: "rabbitmq_data" - volumes: "/var/lib/rabbitmq/" + name: "rabbitmq" + register: rabbitmq_volume - name: Running RabbitMQ bootstrap container kolla_docker: @@ -29,6 +20,7 @@ BOOTSTRAP: name: "rabbitmq_bootstrap" restart_policy: "never" - volumes: "{{ node_config_directory }}/rabbitmq/:{{ container_config_directory }}/:ro" - volumes_from: "rabbitmq_data" - when: exists.rc != 0 + volumes: + - "{{ node_config_directory }}/rabbitmq/:{{ container_config_directory }}/:ro" + - "rabbitmq:/var/lib/rabbitmq/" + when: rabbitmq_volume | changed diff --git a/ansible/roles/rabbitmq/tasks/start.yml b/ansible/roles/rabbitmq/tasks/start.yml index 59d693f3d9..9ed544290a 100644 --- a/ansible/roles/rabbitmq/tasks/start.yml +++ b/ansible/roles/rabbitmq/tasks/start.yml @@ -5,5 +5,6 @@ common_options: "{{ docker_common_options }}" image: "{{ rabbitmq_image_full }}" name: "rabbitmq" - volumes: "{{ node_config_directory }}/rabbitmq/:{{ container_config_directory }}/:ro" - volumes_from: "rabbitmq_data" + volumes: + - "{{ node_config_directory }}/rabbitmq/:{{ container_config_directory }}/:ro" + - "rabbitmq:/var/lib/rabbitmq/"