[chef] Missing Notification from LWRP


Chronological Thread 
  • From: Kevin Christen < >
  • To:
  • Subject: [chef] Missing Notification from LWRP
  • Date: Sat, 11 Feb 2012 09:09:25 -0600

Chef 0.10.8. I have an LWRP for the package resource that doesn't send notifications. I have a very simple test case that demonstrates the problem. Here is the LWRP, from file cookbooks/test/providers/my_package.rb:

action :install do
  Chef::Log.info("installing #{new_resource.name}")
end

Here is my recipe:

package "the_package" do
  provider :test_my_package
  notifies :create, "ruby_block[the_observer]"
end

ruby_block "the_observer" do
  block do
    Chef::Log.info("the observer has been notified")
  end
  action :nothing
end

Here is the result:

...
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: Processing package[the_package] action install (test::the_package line 1)
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: installing the_package
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: Processing ruby_block[the_observer] action nothing (test::the_package line 6)
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: Chef Run complete in 0.006884 seconds
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: Running report handlers
[Sat, 11 Feb 2012 09:02:04 -0600] INFO: Report handlers complete

I expect the install action of the package to send a create notification to the ruby block, which would print "the observer has been notified". I have tried a number of variations of this test case:
  • using subscribes instead of notifies (fails)
  • adding supports :create => true on the ruby block (fails)
  • using a built in provider instead of an LWRP (succeeds)
What am I missing?

Thanks,
Kevin Christen



Archive powered by MHonArc 2.6.16.

§