edelight/chef-mongodb

User management support one user any databases?

supergrilo opened this issue · 3 comments

The user_management recipe can support create an user to use many databases?
something like that

use reporting
db.createUser(
    {
      user: "reportsUser",
      pwd: "12345678",
      roles: [
         { role: "read", db: "reporting" },
         { role: "read", db: "products" },
         { role: "read", db: "sales" },
         { role: "readWrite", db: "accounts" }
      ]
    }
)

@jamesonjlee can you help?

@supergrilo This cook book will install version 2.4.9 of the mongo shell. Version 3 started supporting creating users the way you are creating it. In your version you have to do it this way

use reporting
db.addUser( { user: "reportsUser",
              pwd: "12345678",
              roles: [ "read" ]
            } )

You have to do this for every database. This cookbook is out of date use this one they maybe taking it over https://github.com/chef-brigade/mongodb-cookbook. Here is more info on adding a user with your version http://docs.mongodb.org/v2.4/tutorial/add-user-to-database/.

@ballerabdude this way works on 2.x mongod.

If you need allow user to siwtch between databases, in the same connection session, you need to do this auth configuration in the same database.

maybe turn this issue a feature request?