Mcollective Chef service agent failed to run

99 Views Asked by At

I have configure mcollective and install following service agent to start/stop service

https://github.com/rottenbytes/mcollective/blob/master/plugins/agents/chef-service.rb

But when i running it, its failing at client.build_node and i am seeing error undefined method reset_defaults_and_overrides for nil:NilClass (NoMethodError)

require 'chef'
require 'chef/client'
require 'chef/run_context'
begin

Chef::Config[:solo] = true
Chef::Config[:log_level] = :debug
Chef::Log.level(:debug)
client = Chef::Client.new
client.run_ohai
client.build_node   <-- its failing here 

If i try to run on my shell i get following

[root@node1 agent]# ruby /tmp/foo.rb 
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/policy_builder/expand_node_object.rb:117:in `build_node': undefined method `reset_defaults_and_overrides' for nil:NilClass (NoMethodError)
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:259:in `build_node'
    from /tmp/foo.rb:11:in `<main>'

I am not ruby expert so i don't know how to fix it. I just need clue what is going on

1

There are 1 best solutions below

2
coderanger On

From the looks of it, enough of the internal API for chef client has changed that the mcollective plugin won't work anymore. Try an older version of the chef gem.