Jeffrey Zhang 066173bec0 Implement mongodb replication set cluster
Closes-Bug: #1605457
Change-Id: I1a8e746f79f4dfcc5a43e736c3461b316db3f593
2016-08-20 17:30:29 +00:00

27 lines
996 B
YAML

---
- name: Starting mongodb container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ mongodb_image_full }}"
name: "mongodb"
privileged: True
volumes:
- "{{ node_config_directory }}/mongodb/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "mongodb:/var/lib/mongodb"
- name: Waiting for the mongodb startup
wait_for: host={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} port={{ mongodb_port }}
- name: Checking current replication status
command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --quiet --eval rs.status().ok"
register: mongodb_replication_status
changed_when: false
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- include: "bootstrap_cluster.yml"
when: mongodb_replication_status.stdout != "1"