34 lines
1.1 KiB
YAML

---
- name: Check Docker Service
systemd:
name: docker
enabled: yes
state: started
tags: [mongodb]
- name: Running MongoDB Docker
docker_container:
name: "{{ mongodb_docker_name }}{{ item }}"
hostname: "{{ mongodb_docker_name }}{{ item }}"
image: "{{ mongodb_docker_image }}"
detach: true
published_ports:
- "{{ (mongodb_port|int + item|int)|string }}:{{ mongodb_port }}"
restart_policy: always
volumes:
- "{{ mongodb_host_mount_dir }}{{ item|string }}/db:{{ mongodb_storage_path }}"
- "{{ mongodb_host_mount_dir }}{{ item|string }}/configdb:{{ mongodb_config_path }}"
- "{{ mongodb_host_config }}:/bdb_config"
state: started
keep_volumes: true
entrypoint: /entrypoint.sh --replSet=bigchain-rs
register: mongo_container_info
with_sequence: start=0 end="{{ docker_cluster_size|int - 1 }}" stride=1
tags: [mongodb]
- name: Set facts for MongoDB containers
set_fact:
mongodb{{ item }}={{ mongo_container_info.results[item|int].ansible_facts.docker_container.NetworkSettings.IPAddress }}
with_sequence: start=0 end="{{ docker_cluster_size|int - 1 }}" stride=1
tags: [mongodb]