updated_by_last action from a resource inside a LWP

If I have a lightweight provider that is calling other resources, and I’d like
to know if the resource I called modified anything, so that I can pass that
information along… is there a way to do that?

E.G.

If I am calling the template resource inside my own custom provider, is there a
way to determine if it has called updated_by_last_action so that I can then
call updated_by_last_action on my new_resource?

Hi,

On Mon, Jul 16, 2012 at 6:06 AM, brian.bianco@gmail.com wrote:

If I have a lightweight provider that is calling other resources, and I'd like
to know if the resource I called modified anything, so that I can pass that
information along... is there a way to do that?

E.G.

If I am calling the template resource inside my own custom provider, is there a
way to determine if it has called updated_by_last_action so that I can then
call updated_by_last_action on my new_resource?

Unfortunately you have hit one of the biggest pain points I have found
with Chef. There is no way I have found to do this as they are
separate run contexts. I have tried all sorts of hackery to try to get
this working but I don't think it is possible without monkey patching
the core ... which I have yet to get to. It does mean that resources
are not composable but mostly they are still a better option than
definitions. It would be nice to have some way to be able to notify
the containing resource when things have changed.

--
Cheers,

Peter Donald

On 07/15/2012 06:05 PM, Peter Donald wrote:

Hi,

On Mon, Jul 16, 2012 at 6:06 AM, brian.bianco@gmail.com wrote:

If I have a lightweight provider that is calling other resources, and I'd like
to know if the resource I called modified anything, so that I can pass that
information along... is there a way to do that?

E.G.

If I am calling the template resource inside my own custom provider, is there a
way to determine if it has called updated_by_last_action so that I can then
call updated_by_last_action on my new_resource?

Unfortunately you have hit one of the biggest pain points I have found
with Chef. There is no way I have found to do this as they are
separate run contexts. I have tried all sorts of hackery to try to get
this working but I don't think it is possible without monkey patching
the core ... which I have yet to get to. It does mean that resources
are not composable but mostly they are still a better option than
definitions. It would be nice to have some way to be able to notify
the containing resource when things have changed.

(I'm just postulating here)...

I think you should be able to do this if you force the resource you're
creating to be executed immediately

t = template '...' do
...
action :nothing
end

t.run_action(:run)

updated_by_last_action should be valid here.

Since the execution of your LWRP is done a "run time", so would this (but
would be at the same time as your LWRP, not much late as if you didn't do this).

Disclaimer: I haven't tried this, I'm just riffing based on what I recall from
the core.

--
Phil Dibowitz phil@ipom.com
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