Calling the LWRP from the Exception Handler

Posted by Sarah Haskins on Server Fault See other posts from Server Fault or by Sarah Haskins
Published on 2012-10-23T22:45:59Z Indexed on 2012/10/23 23:02 UTC
Read the original article Hit count: 265

Filed under:
|

Is it possible to call out to a Provider (LWRP) from a Chef Exception Handler? I think my Provider is out of scope, but I don't know if what I am trying to do is possible? or advisable?

Here is my provider code (cookbooks/config/provider/signal.rb):

action :failure do
  Chef::Log.info("Yeah success")
end

Here is my exception handler code (exception_handler/handlers/exceptionHandler.rb):

require 'chef/handler'
config_signal "signal" do
    action :nothing
end

class Chef
  class Handler
    class LogCollector < Chef::Handler
      notifies :failure, resources(:config_signal => signal)
    end
  end
end

Also, if anyone has a good recommendation for general reading about scope in the context of Chef I'd appreciate it.

© Server Fault or respective owner

Related posts about chef

Related posts about chef-solo