# Sc-mongodb user creation fails for me all the time

**URL:** https://discourse.chef.io/t/sc-mongodb-user-creation-fails-for-me-all-the-time/13868
**Category:** Chef Infra (archive)
**Created:** [October 22, 2018, 7:07am UTC](https://discourse.chef.io/t/sc-mongodb-user-creation-fails-for-me-all-the-time/13868 "2018-10-22T07:07:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lnmgeorge](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@lnmgeorge](https://discourse.chef.io/u/lnmgeorge)
#### Post date: [October 22, 2018, 7:07am UTC](https://discourse.chef.io/t/sc-mongodb-user-creation-fails-for-me-all-the-time/13868/1 "2018-10-22T07:07:51Z")

</div>

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
