Commit 278566be by Feanil Patel

Run user creation on condition.

Meant to be used in plays where we use the 'first_in_tag' host vars to only run usercreation on one machine.
parent 5b1e1668
...@@ -27,6 +27,10 @@ MONGO_CLUSTERED: !!null ...@@ -27,6 +27,10 @@ MONGO_CLUSTERED: !!null
mongo_logpath: "{{ mongo_log_dir }}/mongodb.log" mongo_logpath: "{{ mongo_log_dir }}/mongodb.log"
mongo_dbpath: "{{ mongo_data_dir }}/mongodb" mongo_dbpath: "{{ mongo_data_dir }}/mongodb"
# Have to use this conditional instead of ignore errors
# because the mongo_user module fails and doesn't ginore errors.
mongo_create_users: !!null
# If the system is running out of an Amazon Web Services # If the system is running out of an Amazon Web Services
# cloudformation stack, this group name can used to pull out # cloudformation stack, this group name can used to pull out
# the name of the stack the mongo server resides in. # the name of the stack the mongo server resides in.
......
...@@ -66,8 +66,8 @@ ...@@ -66,8 +66,8 @@
shell: /usr/bin/mongo /tmp/repset_init.js shell: /usr/bin/mongo /tmp/repset_init.js
when: MONGO_CLUSTERED when: MONGO_CLUSTERED
# Ignoring errors here because slave instances will fail this command # Ignore errors doesn't work because the module throws an exception
# since slaveOk is false in ansible 1.3. # it doesn't catch.
- name: mongo | create a mongodb user - name: mongo | create a mongodb user
mongodb_user: > mongodb_user: >
database={{ item.database }} database={{ item.database }}
...@@ -75,3 +75,4 @@ ...@@ -75,3 +75,4 @@
password={{ item.password }} password={{ item.password }}
state=present state=present
with_items: MONGO_USERS with_items: MONGO_USERS
when: mongo_create_users
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