- From: Maxim Kulkin <
>
- To:
- Subject: [chef] Controlling ruby_block update status
- Date: Thu, 8 Dec 2011 21:04:24 +0400
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:
ruby_block "Remove unwanted entries" do
block {
entries = Dir["/foo/bar/*"]
entries.reject! { |e| PRECIOUS_ENTRIES.include?(File.basename(e)) }
entries.each { |e| FileUtils.rm_rf(e) }
updated_by_last_action !entries.empty?
}
notifies :restart, 'service[foo]'
end
This way notifications will trigger only if there were actual changes.
To implement this, a simple change is required: inside
"chef/provider/ruby_block.rb" method #action_create should set
updated_by_last_action attribute _before_ running resource block:
def action_create
@new_resource.updated_by_last_action(true)
@new_resource.block.call
Chef::Log.info("
called, update status is set to
")
end
What do you think?
- [chef] Controlling ruby_block update status, Maxim Kulkin, 12/08/2011
Archive powered by MHonArc 2.6.16.