chef: Add a 'null' or 'notifies' NOP resource to hang chained notifies off of

Original request here: https://tickets.opscode.com/browse/CHEF-5324

The item was obviously lost when the issues moved to Github. Chef still has not provided a way to specify a resource call is to execute at the end of the Chef run. The work-around was to have a dummy resource do the notify like as follows:

bash 'dummy-delay-httpd-start' do
  notifies :restart, 'service[httpd]', :delayed
end

service 'httpd' do
  action :nothing
end

However, now a warning is beind thrown that this won’t work anymore in Chef 13:

 WARN: bash[dummy-delay-httpd-start]: No code attribute was given, resource does nothing, this behavior is deprecated and will be removed in Chef-13

You need to either abort the planned removal of this or add the original feature I requested. It’s absurd that there won’t be a way to have something run at the end of a Chef run in all circumstances.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

I think that we need a top-level “notify this resource” dsl method that you can use in recipes. We NACK’d this idea several times in the old code-review sessions, but there are so many use cases that it would facilitate that I think that we were just wrong about that. If we had such a mechanism, you could just do:

service 'httpd' do
  action :nothing
end

notify "service[httpd]" do
  notify_action :restart
  notify_timing :delayed
  action :notify
end

In practice a ruby_block works fine for this, but I think being more explicit would be better. It would also allow us to do validations such as the warning we are producing here.