- From: Ash Berlin <
>
- To:
- Subject: [chef] Re: Re: Dependancy order problem
- Date: Tue, 28 Dec 2010 17:43:57 +0000
On 28 Dec 2010, at 17:29, Bryan McLellan wrote:
>
On Tue, Dec 28, 2010 at 8:48 AM, Ash Berlin
>
<
>
>
wrote:
>
> So I just got bit by a problem (on my staging server luckily) where after
>
> rebooting a host the Chef tried to restart the nginx server
>
> before writing out the new config. But it wouldn't start since it has an
>
> error in the config, so stopped before it wrote out the corrected config...
>
>
I've gotten into this state with Apache too. Getting out of it is even
>
easier now with the new resource notification syntax [1]. I used to do
>
something like this:
>
>
service "apache2" do
>
action :enabled
>
end
>
>
template "/etc/apache2/sites-enabled/foo" do
>
source "foo"
>
owner "root"
>
group "root"
>
mode "0644"
>
notifies :reload, resources(:service => "apache2")
>
end
>
>
service "apache2" do
>
action :start
>
end
>
>
In chef, resources of the same name stack. So anything unique you put
>
into the first service definition is going to still be a part of the
>
object when you call it later.
>
>
Since 0.9.10 there is a new notification syntax that is part of a
>
pre-parser so you don't need to define the service before you have a
>
notification.
>
>
template "/etc/apache2/sites-enabled/foo" do
>
source "foo"
>
owner "root"
>
group "root"
>
mode "0644"
>
notifies :reload, "service[apache2]"
>
end
>
>
service "apache2" do
>
action [ :enabled, :start ]
>
end
>
>
Bryan
>
>
[1] http://wiki.opscode.com/display/chef/Resources#Resources-Notifications
Hmmm i might also be able to do this:
n = service "nginx" do
action [ :enable ]
end
n.notifies :start, n
Which just has the effect of delaying the start till the end of the run (I
think.) Thoughts?
-ash
Archive powered by MHonArc 2.6.16.