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>
This commit is contained in:
ZijianGuo 2019-05-20 11:44:06 +08:00
parent a7d7838689
commit 08f5c50e74

@ -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] }}"