- From: AJ Christensen <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Force recipe to run at the end
- Date: Tue, 2 Oct 2012 14:39:33 +1300
For structured code like this (requires, includes, extends.. code that
spreads multiple files..) I'd suggest moving it out to a Ruby Gem and
using the chef_gem installation method / compile time access.
As Jay mentioned, the libraries are shipped from the server and
evaluated as they are received (IIRC) so you can have potential
ordering issues there when requiring a file that doesn't exist, or
relying on a file to be autoloaded, etc.
Here's an additional example:
http://rubygems.org/gems/flock_of_chefs
https://github.com/chrisroberts/flock_of_chefs/
https://github.com/chrisroberts/cookbook-flock_of_chefs/blob/master/recipes/default.rb
Cheers,
--AJ
On 2 October 2012 14:35, Julien Vehent
<
>
wrote:
>
On 2012-09-26 03:15, Phil Dibowitz wrote:
>
>
>
> On 09/25/2012 07:02 PM, Julien Vehent wrote:
>
>>
>
>> Thanks. I updated the cookbook:
>
>> http://community.opscode.com/cookbooks/afw
>
>> One thing that I'm not 100% comfortable with (despite the great help on
>
>> #chef)
>
>> is how to export a single function from a given module to other
>
>> cookbooks. In
>
>> this case, I have AFW.create_rule() that simply calls the internal
>
>> function
>
>> AFWCore.process_rule(). I'm guessing this could be done better, but being
>
>> primarily a sysadmin/security and not really a rubyist, I'm not sure how.
>
>
>
>
>
> That's totally fine. I only did a quick scan of the code, but if I read it
>
> correctly, create_rule() is just a wrapper for some sanity checking and
>
> then
>
> adding the rule to the node object, right?
>
>
>
> That's completely reasonable. That all then gets added a compile time, and
>
> at
>
> runtime when your template is processed all the data is there.
>
>
>
> Again, I only did a very quick glance at the code, but it seems good in
>
> general.
>
>
>
I have a problem with the "extend" function. This code:
>
>
module AFW
>
extend AFWCore
>
<....>
>
end
>
>
(see https://github.com/jvehent/AFW/blob/master/libraries/create_rule.rb )
>
>
works perfectly fine in chef 10.12, but not in chef <= 10.10.
>
>
Quoting yfeldblum from #chef: "the problem is that there's no total order
>
imposed as part of the API or part of the contract, and there's no supported
>
API way for cookbooks and libraries themselves to request a partial order"
>
>
What would be the right way to do this, while making certain that it won't
>
break earlier/future versions of chef ?
>
>
Thanks,
>
Julien
Archive powered by MHonArc 2.6.16.