[chef] Re: Re: sending notifications to resources that don't exist yet


Chronological Thread 
  • From: Daniel Condomitti < >
  • To:
  • Subject: [chef] Re: Re: sending notifications to resources that don't exist yet
  • Date: Tue, 23 Oct 2012 17:22:28 -0700

That's exactly how we do it. A base application provider defines an empty service and we delay all notifications until after the rest of the app has been configured.

On Tuesday, October 23, 2012 at 5:19 PM, Peter Donald wrote:

Hi,

One way of doing this is to define one resource first but with an "action :nothing", define the second resource that notifies the first and then reopen the first resource but apply actions. i.e. Something like the following (ignore syntax errors as away from editor)

service "foo" do
  action :nothing
end

template "/etc/foo.conf" do 
  notifies :restart, resource(:service => "foo"), :immediate
end

service "foo" do
  action [:enable, :start]
end

HTH

On Wed, Oct 24, 2012 at 10:57 AM, Leo Dirac (SR) < " target="_blank"> > wrote:
Is it possible to send a notification to a resource if the resource hasn't been created yet?  When I try this it blows up complaining that the resource is unknown.  But I don't see any other way to do what I need to.

My application needs a server-specific configuration file, which I create with a template.  The app needs this when it deploys, so I create the template (in /srv/app/shared/) before the app resource, and then symlink it in before deploy.  This basically works.

But the config file itself is templated with attributes.  When those attributes change, I want to restart the application.  But I can't send a notification because the config file needs to be defined before the app.

I tried defining the template inside the application's before_deploy callback, but that doesn't seem to do anything.  This kind of circular dependency problem has to have a standard solution, right?




--
Cheers,

Peter Donald




Archive powered by MHonArc 2.6.16.

§