Skip to content

Commit

Permalink
fix mongoc and mongod templates, also fix replication hosts order in …
Browse files Browse the repository at this point in the history
…hosts file and README.md
  • Loading branch information
Andrej Jechropov authored and Andrej Jechropov committed Nov 5, 2014
1 parent 675fb88 commit b91be84
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mongodb/README.md
Expand Up @@ -104,9 +104,9 @@ The inventory file looks as follows:

#The list of servers where replication should happen, including the master server.
[replication_servers]
mongo3
mongo1
mongo2
mongo3

#The list of mongodb configuration servers, make sure it is 1 or 3
[mongoc_servers]
Expand Down
4 changes: 2 additions & 2 deletions mongodb/hosts
Expand Up @@ -9,10 +9,10 @@ mongo4 mongod_port=2703

#The list of servers where replication should happen, by default include all servers
[replication_servers]
mongo4
mongo3
mongo1
mongo2
mongo3
mongo4

#The list of mongodb configuration servers, make sure it is 1 or 3
[mongoc_servers]
Expand Down
2 changes: 1 addition & 1 deletion mongodb/roles/mongoc/templates/mongoc.conf.j2
Expand Up @@ -12,6 +12,6 @@ port = {{ mongoc_port }}
dbpath={{ mongodb_datadir_prefix }}configdb
keyFile={{ mongodb_datadir_prefix }}secret
# location of pidfile
pidfilepath = /var/run/mongoc.pid
pidfilepath = /var/run/mongo/mongoc.pid

configsvr=true
13 changes: 9 additions & 4 deletions mongodb/roles/mongod/tasks/main.yml
Expand Up @@ -6,15 +6,20 @@
delegate_to: '{{ item }}'
with_items: groups.replication_servers


- name: create data directory for mongodb
file: path=/var/log/mongo state=directory owner=mongod group=mongod

- name: create data 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
template: src=mongod.conf.j2 dest=/etc/mongod-{{ inventory_hostname }}.conf
delegate_to: '{{ item }}'
with_items: groups.replication_servers

Expand All @@ -23,7 +28,7 @@


- name: Start the mongodb service
command: creates=/var/lock/subsys/mongod-${inventory_hostname} /etc/init.d/mongod-${inventory_hostname} start
command: creates=/var/lock/subsys/mongod-{{ inventory_hostname }} /etc/init.d/mongod-{{ inventory_hostname }} start
delegate_to: '{{ item }}'
with_items: groups.replication_servers

Expand All @@ -34,4 +39,4 @@
pause: seconds=20

- name: Initialize the replication set
shell: /usr/bin/mongo --port "{{ mongod_port }}" /tmp/repset_init.js
shell: /usr/bin/mongo --port "{{ mongod_port }}" /tmp/repset_init.js
2 changes: 1 addition & 1 deletion mongodb/roles/mongod/templates/mongod.conf.j2
Expand Up @@ -15,7 +15,7 @@ dbpath={{ mongodb_datadir_prefix }}mongo-{{ inventory_hostname }}
keyFile={{ mongodb_datadir_prefix }}/secret

# location of pidfile
pidfilepath = /var/run/mongod.pid
pidfilepath = /var/run/mongo/mongod-{{ inventory_hostname }}.pid


# Ping interval for Mongo monitoring server.
Expand Down

0 comments on commit b91be84

Please sign in to comment.