- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Controlling ruby_block update status
- Date: Thu, 8 Dec 2011 09:17:39 -0800
On Thursday, December 8, 2011 at 9:04 AM, Maxim Kulkin wrote:
>
Hi all,
>
>
I just found out that "ruby_block" resource is updated every time and this
>
can't be controlled. I think this resource type could benefit from ability
>
to control it's update status from inside block. Use case:
>
...
>
>
>
def action_create
>
@new_resource.updated_by_last_action(true)
>
@new_resource.block.call
>
Chef::Log.info
>
(http://Log.info)("
>
called, update status is set to
>
")
>
end
>
>
What do you think?
In a super-pedantic sense, calling Resource#updated_by_last_action more than
once is incorrect. The reason this was changed from a simple boolean is so
that you can check which resources have been updated at all (say, in a report
handler), whereas the notification system decides to fire notifications when
the last action updated the resource.
For right now, it's not such a big deal, but when we add more support for
storing and querying this info in Chef 11, it could be a problem.
On the other hand, if we forced the user to set
Resource#updated_by_last_action, then we're adding more complexity to what's
a relatively simple thing right now.
At the moment your use case is probably better served by a LWRP. Thinking out
loud, I wonder if something like an "inline LWRP" would be a good balance
between the simplicity of ruby_block and the extra effort required for
LWRPs--and might also be a nicer way to support the dynamic resource use case.
--
Dan DeLeo
Archive powered by MHonArc 2.6.16.