[chef] Re: Re: Chef Exception Handlers and gem dependancies


Chronological Thread 
  • From: Aaron Bento < >
  • To:
  • Subject: [chef] Re: Re: Chef Exception Handlers and gem dependancies
  • Date: Tue, 21 Feb 2012 14:43:25 -0800
  • Authentication-results: mr.google.com; spf=pass (google.com: domain of designates 10.42.161.73 as permitted sender) ; dkim=pass

AJ,
Thanks for your pointers. I had the gem_package in there, but the wrong location. It was in the handler code file. I now have a working setup by making these two changes:

1) Call the gem_package resource in the recipe.
2) Insert gem "pony" at the top of my handler code.

Thanks again!

-- 
Aaron Bento

On Thursday, February 16, 2012 at 6:09 PM, AJ Christensen wrote:

you can use gem_package during the compile phase:

gem_package "foo" do
action :nothing
end.run_action(:install)

This file does exactly what you are talking about, fwiw:

--AJ

On 17 February 2012 15:01, Aaron Bento < "> > wrote:
Hey Everyone,
I'm a bit confused on how to get a gem (or other resource) installed on a
machine that is a dependency for a Chef Exception Handler.

I'm using the EmailMe example from the wiki to familiarize myself with
writing handlers:

I have the example working if I already have the pony gem installed, but
once I try to perform a run on a clean machine, I get:

FATAL: LoadError: no such file to load -- pony

After reading the following wiki page, I thought the proper place was to put
it above the handler code.

However that results in:

FATAL: NoMethodError: chef_handler[MyOrganization::EmailMe]
(chef_handler::email_me line 25) had an error: NoMethodError: undefined
method `gem_package' for main:Object

I seem to be caught in a catch-22. The handler is evaluated during the
compile stage, but I need to install a gem which doesn't happen until the
execute. How are others doing this with gems or other dependancies not on
the system?

I'm using the chef_handler cookbook and pulling the chef handler via the
LWRP in a recipe.

Where is the best place to call gem_package? Thanks!

--
Aaron Bento




Archive powered by MHonArc 2.6.16.

§