kolla-ansible/ansible/roles/mongodb/handlers/main.yml

34 lines
1.2 KiB
YAML

---
- name: Restart mongodb container
vars:
service_name: "mongodb"
service: "{{ mongodb_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
privileged: "{{ service.privileged | default(False) }}"
volumes: "{{ service.volumes }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"
notify:
- Waiting for the mongodb startup
- Checking current replication status
- 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
become: true
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] }}"
run_once: True
- include_tasks: "bootstrap_cluster.yml"
when: mongodb_replication_status.stdout != "1"