kolla-ansible/ansible/roles/mongodb/tasks/bootstrap_cluster.yml
Xing Zhang f7bfce20ad
Fix mongo command for supporting other port
If we change mongodb_port, the command for bootstraping mongodb
should not connect to the default mongodb port 27017.

Change-Id: I330999be577d6416df162ea33fa1f7a19df56029
2019-06-16 18:32:24 +08:00

19 lines
804 B
YAML

---
- name: Copying the mongodb replication set bootstrap script
local_action: template src=bootstrap_cluster.js.j2 dest=/tmp/mongodb_bootstrap_replication_set.js
run_once: True
- name: Bootstrapping the mongodb replication set
become: true
command: "docker exec -t mongodb mongo --host {{ api_interface_address }} --port {{ mongodb_port }} --quiet --eval '{{ lookup('file','/tmp/mongodb_bootstrap_replication_set.js') }}'"
register: bootstrap_mongodb_cluster
failed_when: (bootstrap_mongodb_cluster.stdout|from_json).ok != 1
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- name: Deleting the mongodb replication set bootstrap script
local_action: file path=/tmp/mongodb_bootstrap_replication_set.js state=absent
changed_when: false
failed_when: false
run_once: True