2021-02-03 10:39:11 -05:00
|
|
|
---
|
2021-05-10 19:11:24 -04:00
|
|
|
- name: Permissions for mongo
|
|
|
|
become: yes
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
mode: 0777
|
|
|
|
path: /var/log/mongodb
|
|
|
|
|
2021-05-19 23:01:12 -04:00
|
|
|
- name: Make docker network for newsblurnet
|
|
|
|
become: yes
|
|
|
|
docker_network:
|
|
|
|
name: newsblurnet
|
|
|
|
notify: restart docker
|
|
|
|
|
2021-02-03 10:39:11 -05:00
|
|
|
- name: Start db-mongo docker container
|
|
|
|
become: yes
|
|
|
|
docker_container:
|
2021-02-24 11:56:53 -05:00
|
|
|
name: mongo
|
2021-02-03 10:39:11 -05:00
|
|
|
image: mongo:3.6
|
|
|
|
state: started
|
2021-05-10 18:30:54 -04:00
|
|
|
container_default_behavior: no_defaults
|
2021-02-03 10:39:11 -05:00
|
|
|
restart_policy: unless-stopped
|
2021-05-19 17:26:47 -04:00
|
|
|
networks_cli_compatible: yes
|
2021-05-19 22:03:53 -04:00
|
|
|
network_mode: default
|
2021-05-19 17:26:47 -04:00
|
|
|
networks:
|
|
|
|
- name: newsblurnet
|
|
|
|
ports:
|
|
|
|
- "27017:27017"
|
2021-05-10 19:11:24 -04:00
|
|
|
command: --config /etc/mongod.conf
|
2021-02-03 10:39:11 -05:00
|
|
|
volumes:
|
2021-05-10 18:30:54 -04:00
|
|
|
- /mnt/{{ inventory_hostname | regex_replace('db-|-', '') }}:/data/db
|
|
|
|
- /srv/newsblur/ansible/roles/mongo/templates/mongo.conf:/etc/mongod.conf
|
2021-05-10 18:46:02 -04:00
|
|
|
- /var/log/mongodb/:/var/log/mongodb/
|
2021-02-15 19:13:05 -05:00
|
|
|
|
|
|
|
- name: Register mongo in consul
|
2021-02-23 19:30:28 -05:00
|
|
|
tags: consul
|
2021-02-15 19:13:05 -05:00
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: consul_service.json
|
|
|
|
dest: /etc/consul.d/mongo.json
|
2021-05-10 18:08:04 -04:00
|
|
|
when: (inventory_hostname | regex_replace('[0-9]+', '')) in ['db-mongo', 'db-mongo-secondary'] or inventory_hostname.startswith('db2')
|
2021-02-24 11:56:53 -05:00
|
|
|
notify:
|
|
|
|
- reload consul
|
|
|
|
|
|
|
|
- name: Register mongo-analytics in consul
|
|
|
|
tags: consul
|
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: consul_service.analytics.json
|
|
|
|
dest: /etc/consul.d/mongo.json
|
2021-03-10 16:54:18 -05:00
|
|
|
when: (inventory_hostname | regex_replace('[0-9]+', '')) == 'db-mongo-analytics' or inventory_hostname.startswith('db3')
|
2021-02-15 19:13:05 -05:00
|
|
|
notify:
|
2021-02-23 18:37:56 -05:00
|
|
|
- reload consul
|