-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmongo.yml
39 lines (28 loc) · 1.44 KB
/
mongo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-name: create data directory for mongodb
file: path={{ mongodb_datadir_prefix }}/mongo-{{ inventory_hostname }} state=directory owner=mongod group=mongod
delegate_to: '{{ item }}'
with_items: groups.replication_servers
- name: create log directory for mongodb
file: path=/var/log/mongo state=directory owner=mongod group=mongod
- name: create run directory for mongodb
file: path=/var/run/mongo state=directory owner=mongod group=mongod
- name: Create the mongodb startup file
template: src=mongod.j2 dest=/etc/init.d/mongod-{{ inventory_hostname }} mode=0655
delegate_to: '{{ item }}'
with_items: groups.replication_servers
- name: Create the mongodb configuration file
template: src=mongod.conf.j2 dest=/etc/mongod-{{ inventory_hostname }}.conf
delegate_to: '{{ item }}'
with_items: groups.replication_servers
- name: Copy the keyfile for authentication
copy: src=secret dest={{ mongodb_datadir_prefix }}/secret owner=mongod group=mongod mode=0400
- name: Start the mongodb service
command: creates=/var/lock/subsys/mongod-{{ inventory_hostname }} /etc/init.d/mongod-{{ inventory_hostname }} start
delegate_to: '{{ item }}'
with_items: groups.replication_servers
- name: Create the file to initialize the mongod replica set
template: src=repset_init.j2 dest=/tmp/repset_init.js
- name: Pause for a while
pause: seconds=20
- name: Initialize the replication set
shell: /usr/bin/mongo --port "{{ mongod_port }}" /tmp/repset_init.js