From 6bb01bd7b1a6a8e50469ba6e606fb3689ae2f60d Mon Sep 17 00:00:00 2001
From: Xing Zhang <angeiv.zhang@gmail.com>
Date: Thu, 13 Jun 2019 23:56:15 +0800
Subject: [PATCH] Fix checking mongodb replication status

backport: stein, rocky

The reason it did not work before was that the other handlers had never been called
after [0], tasks from start.yml were move to handler which cannot act
like tasks, also bootstrap tasks must run after 'Restart mongodb container'.

This commit adds a notify after 'Restart mongodb container' for triger
task 'bootstrap_cluster.yml'.

[0] https://github.com/openstack/kolla-ansible/commit/40b635b9c538e3d971f6e40db4fb3900135117e6

Change-Id: I4e2fbe9a8f20afcc4e25a01e23e5231e74eeeec4
---
 ansible/roles/mongodb/handlers/main.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/mongodb/handlers/main.yml b/ansible/roles/mongodb/handlers/main.yml
index ee5f442231..7d678497c2 100644
--- a/ansible/roles/mongodb/handlers/main.yml
+++ b/ansible/roles/mongodb/handlers/main.yml
@@ -25,6 +25,7 @@
   notify:
     - Waiting for the mongodb startup
     - Checking current replication status
+    - Bootstrap cluster
 
 - name: Waiting for the mongodb startup
   wait_for: host={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} port={{ mongodb_port }}
@@ -37,5 +38,6 @@
   delegate_to: "{{ groups['mongodb'][0] }}"
   run_once: True
 
-- include_tasks: "bootstrap_cluster.yml"
+- name: Bootstrap cluster
+  include_tasks: "bootstrap_cluster.yml"
   when: mongodb_replication_status.stdout != "1"