Hi All,

I am using below ansible script to create admin user in mongoDB, 

    - name: Enable at boot and start mongodb
      service: name=mongod.service enabled=yes state=started

    - name: Add the admin user to the replicaset
      mongodb_user: database=admin name=admin password={{ mongo_admin_pass 
}} login_port={{ mongod_port }} roles='root' state=present
      ignore_errors: yes

    - name: Create the file to initialize the replicaset
      template: src=repset_init.j2 dest=/tmp/repset_init.js

    - name: Initialize the replication set on the primary
      shell: /usr/bin/mongo -u admin -p {{ mongo_admin_pass }} 
--authenticationDatabase admin /tmp/repset_init.js
      run_once: true


After creating admin user i want to create normal db user also, example 
user "gray" with permission to db graylog,  see the  script below, but its 
not allowing to create second user 

- name: Create the unauthenticated mongodb configuration file
  template: src=mongod_unauthenticated.conf.j2 dest=/etc/mongod.conf

- name: Enable at boot and start mongodb
  service: name=mongod.service enabled=yes state=started

- name: Add the admin user to the replicaset
  mongodb_user: database=admin name=admin password={{ mongo_admin_pass }} 
login_port={{ mongod_port }} roles='root' state=present
  ignore_errors: yes

- name: Add the graylog user to the replicaset
  mongodb_user: database=graylog name=gray password=gray login_port={{ 
mongod_port }} roles='dbOwner' state=present
  ignore_errors: yes

- name: Create the file to initialize the replicaset
  template: src=repset_init.j2 dest=/tmp/repset_init.js

- name: Initialize the replication set on the primary
  shell: /usr/bin/mongo -u admin -p {{ mongo_admin_pass }} 
--authenticationDatabase admin /tmp/repset_init.js
  run_once: true



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0d22dab6-7285-4fa3-bd68-be69230ddcba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to