- From: Phil Dibowitz <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: updated_by_last action from a resource inside a LWP
- Date: Wed, 18 Jul 2012 11:48:22 -0700
On Tue, Jul 17, 2012 at 11:47:40AM +1000, Peter Donald wrote:
>
Hi,
>
>
On Tue, Jul 17, 2012 at 1:30 AM,
>
<
>
>
wrote:
>
> yfeldblum pointed me to a great pattern for dealing with this. Here is
>
> the
>
> gist
>
>
>
> https://gist.github.com/d85be145f3ff824ccc07/0e97d44f20ec65411b141cb46cbeb19bb34b44ad
>
>
>
> The general idea is you cache your current run_context, create a new one,
>
> blank
>
> out the resource collection, perform all your resource actions. Then you
>
> restore the run_context back to the original and converge on the new run
>
> context you created. This sub run context contains the subset of
>
> resources
>
> acted upon in your provider. Then you call converge on the sub run
>
> context and
>
> check each of its resources to see if they were updated. If any did get
>
> updated you pass that along to your new_resource.
>
>
>
> Awesome and nifty. I implemented in my redisio cookbook in the install
>
> provider and it seems to work great.
>
>
Awesome indeed. I have tested it out and it works fine and dandy for
>
me. Except we have lots of LWRPs so doing this everytime would be
>
tiresome. I abstracted the essential goodness into a method
>
notifying_action and now most of my providers look something like
>
>
notifying_action :run do
>
file "/tmp/something" do
>
owner "root"
>
group "root"
>
mode "0755"
>
action :create
>
end
>
end
>
>
Much nicer!
>
>
Anyhoo I documented for posterity at
>
>
http://realityforge.org/code/2012/07/17/lwrp-notify-on-changed-resources.html
Nice, I've grabbed this for my use. Thanks!
We should probably work this into LWRPs natively at some point.
--
Phil Dibowitz
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/
"Be who you are and say what you feel, because those who mind don't matter
and those who matter don't mind."
- Dr. Seuss
Attachment:
signature.asc
Description: Digital signature
Archive powered by MHonArc 2.6.16.