- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: Good example of a lwrp
- Date: Fri, 21 Dec 2012 15:19:16 -0800
On Friday, December 21, 2012 at 2:54 PM, Maven User wrote:
Hmmm - some new weirdness...
I have a block of ruby code like this in the provider:
Dir["/srv/#{new_resource.artifactid}-#{new_resource.version}/templates/**/*"].each do |file|
puts "here is the file #{file}"
....
The first time a recipe is run that is using this provider, that evaluates to nothing, so the subsequent lines are skipped.
It also seems to run some of the steps out of order (right above this block in the provider is an unzip step which now is run AFTER the Dir bit...).
Am I missing something?
Short: This is basically the LWRP version of the compile/converge phase issue. Use action :nothing and run_action to make resources execute immediately.
Long:
LWRPs currently handle nested resources by inserting them in the top-level resource collection *after* the LWRP's position in the resource collection. For a recipe like this:
resource_one
lwrp_resource -> sub_resource_one, sub_resource_two
resource_three
…after lwrp_resource is converged, your resource collection looks like:
resource_one #already executed
lwrp_resource #already executed
sub_resource_one
sub_resource_two
resource_three
This implementation was chosen so that the "sub resources" within an LWRP could notify resources outside of the LWRP. The downside is that the LWRP resource itself cannot properly determine if it was updated or not. See:
http://tickets.opscode.com/browse/CHEF-2336
http://tickets.opscode.com/browse/CHEF-3681
https://github.com/opscode/chef/pull/564
In either of the "insert after" or "inline recipe" implementations, you'll still have the general compile/converge pattern, which means that raw ruby code that's not wrapped in a ruby block will execute *before* resources, unless you force the issue with #run_action.
Another option for implementing LWRPs would be to scrap the compile/converge distinction altogether, but then notifications are pretty much impossible, which makes anything that wants to trigger an execute resource based on something else being updated (like a config file) much more difficult to write.
--
Daniel DeLeo
- [chef] Re: Re: Good example of a lwrp, Kevin Christen, 12/01/2012
- <Possible follow-up(s)>
- [chef] Re: Re: Good example of a lwrp, Loïc Antoine-Gombeaud, 12/05/2012
- [chef] Re: Re: Good example of a lwrp, Maven User, 12/20/2012
- [chef] Re: Re: Re: Good example of a lwrp, Daniel Condomitti, 12/20/2012
- [chef] Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/20/2012
- [chef] Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Good example of a lwrp, Daniel DeLeo, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp, Daniel DeLeo, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp, Maven User, 12/21/2012
Archive powered by MHonArc 2.6.16.