Closed st-h closed 6 years ago
I just ran into this. Got it to compile by setting node.default['mongodb']['config']['mongod']['replication']['replSetName'] = 'something'
(still getting errors but seems a different issue now)
Did you resolve it? I'm facing the same issue.
No, I gave up and wrote an internal cookbook for mongodb that is simpler since it only has to fulfill our use case (replicaset with auth, but no sharding or MMS). Sorry I can't be of more help.
@JustLeo I could not find any time to look further into it so far and unfortunately it seems it won't get much better in the near future. I think there are at least two options:
We are going with option two for now, but this isn't quite production code yet, so we are ok with that until we can find the time or this gets more urgent for us.
I don't think this is a bug but the documentation could be bit more clear. If you're setting the node.default['mongodb']['config']['mongod']['replication']['replSetName'] attribute in a wrapper cookbook, like I was trying to do, it'll bomb out at the beginning of the chef run because the attribute won't get set until the recipe in the wrapper runs. Setting the attribute in the role or environment, so the attribute is set at the start of the chef run will get you past the 400 error. Now if I can only figure out why enabling replication breaks adding users, I'd be in good shape.
@DrHappyAngry sorry about the late reply, but I can not really reproduce this. I have all the attributes set in an attributes file. However when I converge with up to date chef, I receive a different error:
ruby_block[config_replicaset] action run
================================================================================
Error executing action `run` on resource 'ruby_block[config_replicaset]'
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/sc-mongodb/libraries/mongodb.rb:74:in `configure_replicaset'
/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:246:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb
244: ruby_block 'config_replicaset' do
245: block do
246: MongoDB.configure_replicaset(node, replicaset_name, rs_nodes) unless new_resource.replicaset.nil?
247: end
248: action :nothing
249: end
250:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:244:in `block in from_file'
ruby_block("config_replicaset") do
params {:mongodb_type=>"mongod", :action=>[:enable, :start], :logpath=>"/var/log/mongodb/mongod.log", :configservers=>[], :replicaset=>true, :notifies=>[], :not_if=>[], :name=>"mongod"}
action [:nothing]
default_guard_interpreter :default
declared_type :ruby_block
cookbook_name "sc-mongodb"
recipe_name "replicaset"
block #<Proc:0x0000000004eff6d8@/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:245>
block_name "config_replicaset"
end
System Info:
------------
chef_version=14.2.0
platform=ubuntu
platform_version=16.04
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client
maybe I was missing a param back then, as other issues like #178 seem to indicate. However, the good news: the above mentioned error seems to be fixed, but not yet released as mentioned here #197 and here #186.
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.
when there only is a single node in the replicaset (for instance when running a node with mms monitoring and backup enabled), the recipe fails with the autoconfigure setting
node['mongodb']['auto_configure']['replicaset'] = true
, returning http 400 "Bad Request"when autoconfigure is set to false, the recipe runs successfully, however the replicaset is not initialized.
chef-stacktrace.out: