[chef] Re: Re: Re: Re: How to add ruby lib as depend at LWRP


Chronological Thread 
  • From: Juan Jesús Ojeda Croissier < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: How to add ruby lib as depend at LWRP
  • Date: Tue, 13 Dec 2011 18:02:42 +0100

Hi Zac,

On Tue, Dec 13, 2011 at 4:55 PM, Zac Stevens 
< >
 wrote:
> Hi,
>
> 2011/12/13 Juan Jesús Ojeda Croissier 
> < >:
>> On Tue, Dec 13, 2011 at 1:08 PM, Bryan Berry 
>> < >
>>  wrote:
>>> # at beginning of lwrp
>>> f = package "foo" do
>>>   action :install
>>> end
>>> f.run_action(:install)
>>>
>>> this might trigger the install action immediately
>>
>> Like that, doesn't work, but I think is good start. After some tries I got:
>
> Bryan's advice is basically correct, but you will also need to reload
> Gem's cache.  See this article for information:
>
> http://www.opscode.com/blog/2009/06/01/cool-chef-tricks-install-and-use-rubygems-in-a-chef-run/
>
> If you are trying this and it doesn't work, could you please include
> more information about how it fails?  The right solution should not be
> so complicated as to manually create a RunContext in your recipes.
>

I know it shouldn't be so complicated, but the the Bryan's solution
doesn't work like that, because I need the library installed at the
node for the provider. I mean, before my provider (LWRP) is loaded.

The 'require' is at the provider, so use the package resource from the
recipe doesn't help at all. The compile fails before the recipe is
even loaded.

Here is the original I trying to fix:
https://github.com/gecos-team/cookbook-bookmarks/blob/master/providers/bookmarks.rb

As I said before, If I try to put Bryan's code there (before the
'require'), chef-client tell me:
FATAL: NoMethodError: undefined method `package' for #<Class:0xb6c8998c>

Because there is no resource 'package' loaded at this point. That's
whay I was trying with Chef::Resource::Package.new and so on.

I don't think either create manually RunContext or any similar
solution would be a good idea, so I guess I'm going to create a new
cookbook with a simple recipe to install the library and make this
cookbook a dependency of my current one.
At least this will work and is not so ugly...

Thanks for the help to all of you :-)

-- 
Juanje



Archive powered by MHonArc 2.6.16.

§