diff --git a/mongodb/README.md b/mongodb/README.md index 5b6e03184..78bf954ec 100644 --- a/mongodb/README.md +++ b/mongodb/README.md @@ -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] diff --git a/mongodb/hosts b/mongodb/hosts index d5bd5f69f..1c945a8c1 100644 --- a/mongodb/hosts +++ b/mongodb/hosts @@ -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] diff --git a/mongodb/roles/mongoc/templates/mongoc.conf.j2 b/mongodb/roles/mongoc/templates/mongoc.conf.j2 index 705f0c01b..f674890b1 100644 --- a/mongodb/roles/mongoc/templates/mongoc.conf.j2 +++ b/mongodb/roles/mongoc/templates/mongoc.conf.j2 @@ -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 diff --git a/mongodb/roles/mongod/tasks/main.yml b/mongodb/roles/mongod/tasks/main.yml index 53f263dd0..fc2961165 100644 --- a/mongodb/roles/mongod/tasks/main.yml +++ b/mongodb/roles/mongod/tasks/main.yml @@ -6,7 +6,12 @@ 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 }}' @@ -14,7 +19,7 @@ - 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 @@ -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 @@ -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 diff --git a/mongodb/roles/mongod/templates/mongod.conf.j2 b/mongodb/roles/mongod/templates/mongod.conf.j2 index 49ced16b5..bf96f4fc3 100644 --- a/mongodb/roles/mongod/templates/mongod.conf.j2 +++ b/mongodb/roles/mongod/templates/mongod.conf.j2 @@ -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.