Commit 9323a427 by John Jarvis

updating from master, merge conflicts

parents 1030fd7a c3d104fd
mongo_dbpath: /var/lib/mongodb
mongo_logpath: /var/log/mongodb/mongodb.log mongo_logpath: /var/log/mongodb/mongodb.log
mongo_logappend: true mongo_logappend: true
mongo_version: 2.4.7 mongo_version: 2.4.7
mongo_bind_ip: 127.0.0.1 mongo_bind_ip: 127.0.0.1
mongo_extra_conf: '' mongo_extra_conf: ''
mongo_key_file: '/etc/mongodb_key'
mongo_repl_set: rs0
mongo_cluster_members:
mongo_data_dir: "{{ data_dir }}/mongo" mongo_data_dir: "{{ data_dir }}/mongo"
mongo_app_dir: "{{ app_dir }}/mongo" mongo_app_dir: "{{ app_dir }}/mongo"
mongo_dbpath: "{{ mongo_data_dir }}/mongodb" mongo_dbpath: "{{ mongo_data_dir }}/mongodb"
......
--- ---
- name: mongo | install python pymongo for mongo_user ansible module - name: mongo | install python pymongo for mongo_user ansible module
pip: > pip: >
name=pymongo state=present name=pymongo state=present
...@@ -39,6 +38,16 @@ ...@@ -39,6 +38,16 @@
- name: mongo | move mongodb to {{ mongo_data_dir }} - name: mongo | move mongodb to {{ mongo_data_dir }}
command: mv /var/lib/mongodb {{ mongo_data_dir}}/. creates={{ mongo_data_dir }}/mongodb command: mv /var/lib/mongodb {{ mongo_data_dir}}/. creates={{ mongo_data_dir }}/mongodb
- name: mongo | copy mongodb key file
copy: >
src={{ secure_dir }}/files/mongo_key
dest={{ mongo_key_file }}
mode=0600
owner=mongodb
group=mongodb
when: mongo_clustered is defined
- name: mongo | copy configuration template - name: mongo | copy configuration template
template: src=mongodb.conf.j2 dest=/etc/mongodb.conf backup=yes template: src=mongodb.conf.j2 dest=/etc/mongodb.conf backup=yes
notify: restart mongo notify: restart mongo
...@@ -49,6 +58,15 @@ ...@@ -49,6 +58,15 @@
- name: mongo | wait for mongo server to start - name: mongo | wait for mongo server to start
wait_for: port=27017 delay=2 wait_for: port=27017 delay=2
- name: mongo | Create the file to initialize the mongod replica set
template: src=repset_init.j2 dest=/tmp/repset_init.js
when: mongo_clustered is defined
- name: mongo | Initialize the replication set
shell: /usr/bin/mongo /tmp/repset_init.js
# Ignoring errors here because slave instances will fail this command
# since slaveOk is false in ansible 1.3.
- name: mongo | create a mongodb user - name: mongo | create a mongodb user
mongodb_user: > mongodb_user: >
database={{ item.database }} database={{ item.database }}
......
...@@ -15,6 +15,11 @@ bind_ip = {{ mongo_bind_ip }} ...@@ -15,6 +15,11 @@ bind_ip = {{ mongo_bind_ip }}
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true journal=true
{% if mongo_clustered is defined %}
keyFile = {{ mongo_key_file }}
replSet = {{ mongo_repl_set }}
{% endif %}
# Enables periodic logging of CPU utilization and I/O wait # Enables periodic logging of CPU utilization and I/O wait
#cpu = true #cpu = true
...@@ -93,4 +98,4 @@ journal=true ...@@ -93,4 +98,4 @@ journal=true
# Size limit for in-memory storage of op ids. # Size limit for in-memory storage of op ids.
#opIdMem = <bytes> #opIdMem = <bytes>
{{ mongo_extra_conf }} {{ mongo_extra_conf }}
\ No newline at end of file
config = {_id: '{{ mongo_repl_set }}', members: [
{% for host in mongo_cluster_members %}
{_id: {{ loop.index }}, host: '{{ host }}'}{% if not loop.last %},{% endif %}
{% endfor %}
]};
rs.initiate(config)
sleep(30000)
rs.slaveOk()
printjson(rs.status())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment