Sc-mongodb user creation fails for me all the time


#1

Hi

I am facing an issue with sc-mongo cookbook for user-management recipe and mongodb_user resource.
This is on ubuntu OS.

For user management recipe i tried with the following code

node.default['mongodb']['config']['auth'] = true
node.default['mongodb']['admin']['username'] = 'admin'
node.default['mongodb']['admin']['password'] = db_passwords["mongodb_password"]
node.default['mongodb']['admin']["roles"] = ['userAdminAnyDatabase']
node.default['mongodb']['admin']["database"] = 'admin'
node.default['mongodb']['admin']['passwordDigestor'] = 'client'

include_recipe 'sc-mongodb::user_management'

where db_passwords is a data bag. I am not sure if this needs to be encrypted.

Then i tried with the resource

connection_Hash = { "retries"=>2, "delay"=>2 }

mongodb_user 'mgeorge' do
username 'mgeorge'
password 'password'
roles ['userAdminAnyDatabase']
database 'admin'
connection connection_Hash
end

That gave me this error

[2018-10-22T06:36:10+00:00] FATAL: NoMethodError: sc_mongodb_user[mgeorge] (role_gateway::default line 45) had an error: NoMethodError: undefined method []' for nil:NilClass [2018-10-22T06:36:10+00:00] FATAL: NoMethodError: sc_mongodb_user[mgeorge] (role_gateway::default line 45) had an error: NoMethodError: undefined method' for nil:NilClass

Could you please review and let me know if i a missed something