From 08f5c50e7491c29138049237ede070d84cc503b8 Mon Sep 17 00:00:00 2001
From: ZijianGuo <guozijn@gmail.com>
Date: Mon, 20 May 2019 11:44:06 +0800
Subject: [PATCH] Fix mongo command for checking replication status

By default, the mongo command connection address is '127.0.0.1:27017'.
If we change mongodb_port, It cause the handle 'Checking current
replication status' always connect to '127.0.0.1:27017'. So we need
add options like '--host' and '--port'.

Change-Id: I172ef3d19ff2bea97db3a5207c1a984cd188ceba
Signed-off-by: ZijianGuo <guozijn@gmail.com>
---
 ansible/roles/mongodb/handlers/main.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ansible/roles/mongodb/handlers/main.yml b/ansible/roles/mongodb/handlers/main.yml
index a1210e67fa..ee5f442231 100644
--- a/ansible/roles/mongodb/handlers/main.yml
+++ b/ansible/roles/mongodb/handlers/main.yml
@@ -31,7 +31,7 @@
 
 - name: Checking current replication status
   become: true
-  command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --quiet --eval rs.status().ok"
+  command: "docker exec -t mongodb mongo --host {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --port {{ mongodb_port }} --quiet --eval rs.status().ok"
   register: mongodb_replication_status
   changed_when: false
   delegate_to: "{{ groups['mongodb'][0] }}"