Closed gtaber closed 9 years ago
This is probably the issue fixed by PR #29 . It can be also fixed from a wrapper cookbook:
node.default['mongodb']['ruby_gems'] = {
:mongo => '~> 1.12',
:bson_ext => nil
}
@gtaber Can you confirm you are on the latest version of the cookbook and it contains the changes listed here https://github.com/chef-brigade/mongodb-cookbook/pull/29. Does the issue still persist?
actually @triccardi-systran Wouldn't this same issue we just closed apply here? https://github.com/chef-brigade/mongodb-cookbook/pull/39 We removed chef_gem for usage in a few recipes but didn't update the user_management recipe.
I do have the most current pull from the repo and this may be simply a situation of me not using the recipe properly. In order to fire off the user_management recipe, I’d need to have "node['mongodb']['config']['auth'] = true” set within the recipe user_management or in another location?
@gtaber You will want to set that variable likely at another level as you won't want to edit the user_management recipe directly. You can try setting that attribute in a role or wrapper cookbook. I included a sample role that you can apply to that node setting that attribute true while also including the user_management recipe.
name "mongo_user"
description "role for mongodb user management"
run_list %w[
recipe[mongodb::user_management]
]
default_attributes(
mongodb: {
config: {
auth: true
}
}
)
Thanks. So I've included this recipe in this new role and I'm still getting the exact same error related to "uninitialized constant Mongo::MongoClient".
{ "name": "mongodb_user", "description": "Role for MongoDB Usermanagement", "json_class": "Chef::Role", "default_attributes": { "mongodb": { "config": { "auth": true } } }, "override_attributes": { }, "chef_type": "role", "run_list": [ "recipe[mongodb::user_management]" ], "env_run_lists": { } }
Here's the stacktrace.
NameError: mongodb_user[admin](mongodb::user_management line 14) had an error: NameError: uninitialized constant Mongo::MongoClient
/var/chef/cache/cookbooks/mongodb/providers/user.rb:62:in retrieve_db' /var/chef/cache/cookbooks/mongodb/providers/user.rb:9:in
add_user'
/var/chef/cache/cookbooks/mongodb/providers/user.rb:71:in block in class_from_file' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider/lwrp_base.rb:138:in
instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider/lwrp_base.rb:138:in block in action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider.rb:118:in
run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource.rb:625:in run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:49:in
run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in block (2 levels) in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in
each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in block in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection.rb:98:in
block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in
call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:85:in step' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:104:in
iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:55:in each_with_index' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection.rb:96:in
execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:80:in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:429:in
converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:494:in do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:199:in
block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:193:in fork' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:193:in
run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application.rb:183:in run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:302:in
block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:294:in loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:294:in
run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application.rb:66:in run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/bin/chef-client:26:in
<top (required)>'
/usr/bin/chef-client:23:in load' /usr/bin/chef-client:23:in
Currently I'm using this setup:
roles/mongodb.json
{
"name": "mongodb",
"json_class": "Chef::Role",
"description": "MongoDB instance",
"chef_type": "role",
"run_list": [
"mongodb::default",
"mongodb::user_management"
],
"default_attributes": {
"mongodb": {
"install_method": "10gen",
"config": {
"auth": true
},
"admin": {
"username": "admin",
"password": "xxxxxxxxxxxx",
"roles": ["root", "userAdminAnyDatabase", "dbAdminAnyDatabase"],
"database": "admin"
},
"users": [
{
"username": "username",
"password": "xxxxxxxxxxxxx",
"roles": ["dbOwner"],
"database": "mydatabase"
}
]
}
}
}
Anyways I'm going to check this with the last merges, just in case…
Can you manually check that the version in your cookbooks/mongodb includes these changes ? https://github.com/chef-brigade/mongodb-cookbook/pull/29/files
Thanks. I've created a new role using your code below (changing the passwords) and I'm still getting the same error when running this role to spin up a new single mongodb instance with those users. The DB is created perfectly but the script bombs when it tries to create the users. Same error as before.
Can you spin up a new DB and have those users created successfully?
I've pulled the latest and confirmed the correct version 0.16.3, and that those changes are already in place in the default.rb and user_management.rb. With the role mentioned earlier in place, I'm still getting this error when running the role that includes both mongodb::default and mongodb::user_management.
NameError uninitialized constant Mongo::MongoClient
Can you confirm you can spin up a new DB instance with those users created successfully?
Stacktrace shown below from this morning's run.
Generated at 2015-07-09 07:58:41 -0700 NameError: mongodb_user[admin] (mongodb::user_management line 14) had an error: NameError: uninitialized constant Mongo::MongoClient /var/chef/cache/cookbooks/mongodb/providers/user.rb:62:in
retrieve_db'
/var/chef/cache/cookbooks/mongodb/providers/user.rb:9:in add_user' /var/chef/cache/cookbooks/mongodb/providers/user.rb:71:in
block in class_from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider/lwrp_base.rb:138:in instance_eval' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider/lwrp_base.rb:138:in
block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider.rb:118:in run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource.rb:625:in
run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:49:in run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in
block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in each' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:81:in
block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection.rb:98:in block in execute_each_resource' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in
call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in call_iterator_block' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:85:in
step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:104:in iterate' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection/stepable_iterator.rb:55:in
each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/resource_collection.rb:96:in execute_each_resource' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/runner.rb:80:in
converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:429:in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:494:in
do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:199:in block in run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:193:in
fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/client.rb:193:in run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application.rb:183:in
run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:302:in block in run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:294:in
loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/client.rb:294:in run_application' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application.rb:66:in
run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/bin/chef-client:26:in <top (required)>' /usr/bin/chef-client:23:in
load'
/usr/bin/chef-client:23:in <main>'
Hi @gtaber I've setup this project for testing https://github.com/luishdez/mongodb-cookbook-playground using the master branch.
It looks ok. I've run librarian-chef install && vagrant up
and everything went fine.
I've only tested with CentOS 6 though… What's your SO ?
for sure dumb question but you're using this repo in your Cheffile… right ?
cookbook "mongodb",
:git => "https://github.com/chef-brigade/mongodb-cookbook.git",
:ref => "master"
I've tested with Ubuntu, Centos … and went ok.
@gtaber tested in a new VM with no problem. So I guess he had some conflicts with ruby and its gems
I'm closing this.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Admittedly I'm relatively new to chef and am in the process of using the mongodb-cookbook. I've got the process of actually creating a standalong mongodb instance working fine. It's understanding how to use the subsequent user_management recipe to create the initial admin user and regular users.
When I add "default['mongodb']['config']['auth'] = true" to the attributes/default.rb file, and run the mongodb::default recipe, the db is created and authentication is on. However I'm getting this error when running the user_management recipe.