- From: <
>
- To:
- Subject: [chef] LWRP and new_resource.updated_by_last_action
- Date: Wed, 30 Nov 2011 07:01:32 -0800 (PST)
I'm trying to get my LWRP resource - which just a collection of other
resources
- to tell it's "invoker" that it changed. The invoker does this:
ruby_block "display_changed" do
action :nothing
block do
Chef::Log.info "RESOURCE CHANGED!!!!!"
end
end
myresource "myresource_name" do
action :install
version "360"
notifies :create, resources(:ruby_block => "display_changed"),
:immediately
end
if, in the "myresource" provider :install action I do a direct
new_resource.updated_by_last_action(true), then the "display_changed"
ruby_block does get executed BUT before all the LWRP resources get processed.
If however I do THIS in the provider;
ruby_block "set_changed" do
action :nothing
block do
new_resource.updated_by_last_action(true)
Chef::Log.info "PROVIDER CHANGED!!!!!"
end
end
execute "install_component" do
command "tar --no-same-owner -xzf #{component_local_archive}"
cwd "#{component_path}"
user "#{component_owner}"
group "#{component_group}"
not_if "test -d {component_path}/bin"
notifies :create, resources(:ruby_block => "set_changed"),
:immediately
end
ruby_block "display_changed" do
block do
Chef::Log.info "CHANGED =
#{new_resource.updated_by_last_action?}"
end
end
and {component_path}/bin does not exist, then "set_changed" gets executed and
display_changed displays "CHANGED = true" (i.e. business as expected) BUT the
"invoking resource" does NOT see the change.
if {component_path}/bin does exist then "set_changed" does not get executed
and
display_changed displays "CHANGED = false" i.e. business as expected.
Any way out of this?
- [chef] LWRP and new_resource.updated_by_last_action, martin.j.bartlett, 11/30/2011
Archive powered by MHonArc 2.6.16.