[chef] Re: How to use custom chef-handlers?


Chronological Thread 
  • From: Tim Green < >
  • To:
  • Subject: [chef] Re: How to use custom chef-handlers?
  • Date: Wed, 8 Aug 2012 14:50:57 -0400

The repo that you pointed to only has a module named 'updated_resources.rb', so your require statement should reflect this (unless the gem has a completely different filename, which I doubt).

A quick suggestion that might make things easier for you.  One good pattern for using chef_handler is:

1. Write your handler.  In this case you've already got @jtimberman's to start with.
2. Drop the file with the contents of the handler into ./chef-repo/cookbooks/chef_handler/files/default/handlers/<handler_name>.rb
3. Declare the 'chef_handler' resource inside of ./chef-repo/cookbooks/chef_handler/recipes/default.rb
4. Prefix your run_list with the handler, or at least ensure it runs before any of the recipes in the run_list that use the handler.

For a more thorough treatment of handlers (in case my explanation isn't enough), have a look here: http://wiki.opscode.com/display/chef/Distributing+Chef+Handlers

Hope this helps.

-Tim

On Wednesday, August 8, 2012 at 2:25 PM, Sachin Sagar Rai wrote:

Ohai!

I tried to use custom-handler with chef-servers, I mean not chef-solo,  and in particular this https://github.com/jtimberman/chef-handler-updated-resources simple one by @jtimberman 
But it errors out everytime.

Following is the recipe ( I tried with different ways):

    include_recipe "chef_handler"

    chef_gem "chef-handler-updated-resources"
    gem "chef-handler-updated-resources"
     
    # r = gem_package "chef-handler-updated-resources" do
    #   action :nothing
    # end 
    # r.run_action(:install)
    # Gem.clear_paths

    # require 'chef-handler-updated-resources'

    chef_handler "SimpleReport::UpdatedResources" do
      action :nothing
    end.run_action(:enable)

But always errors out. The -l debug is here: https://gist.github.com/3296700

Whats wrong with  `require "chef-handler-updated-resources"` ???
-------------------------------------------
@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow





Archive powered by MHonArc 2.6.16.

§