- From: Adam Jacob <
>
- To:
- Cc: Avleen Vig <
>
- Subject: [chef] Re: Re: Problem with chef recipe run order
- Date: Tue, 22 Feb 2011 16:38:15 -0800
Right - the issue is that the resources have the same name, which
means you are inheriting the not_if.
You can turn this:
syslog-ng::default:
cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
not_if "grep 'SPECIAL CONFIG' /etc/syslog-ng/syslog-ng.conf"
source "genericv2.conf"
owner "root"
group "root"
mode 00644
notifies :restart, resources(:service => "syslog-ng")
end
syslog-ng::prod-web
cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
backup false
source "prodweb-syslog-ng.conf"
owner "root"
group "root"
mode 00644
notifies :restart, resources(:service => "syslog-ng")
end
Into this:
syslog-ng::default:
cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
source "genericv2.conf"
owner "root"
group "root"
mode 00644
notifies :restart, resources(:service => "syslog-ng")
end
syslog-ng::prod-web
cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
source "prodweb-syslog-ng.conf"
end
And you'll get the effect you are looking for. The resource will get
applied where it appears first in the run list, which is in the
"syslog-ng" recipe.
Adam
On Tue, Feb 22, 2011 at 4:26 PM, Avleen Vig
<
>
wrote:
>
(sorry for the top post - short and probably more appropriate)
>
>
I think I found the cause here:
>
http://lists.opscode.com/sympa/arc/chef/2010-02/msg00088.html
>
The idempotent nature of not_if is causing the problem to appear.
>
>
When I looked at the debug output and saw the not_if being applied in
>
the syslog-ng::prod-web recipe, I assumed the ::default recipe was not
>
being run until later.
>
I'm not sure if this is the case or not yet (it shouldn't be, but..).
>
The not_if statement was being carried forward which resulted in this.
>
>
:-)
>
>
On Tue, Feb 22, 2011 at 3:48 PM, Avleen Vig
>
<
>
>
wrote:
>
> This is bizarre - though it may be my lack of understanding of chef :-)
>
> Anyone know what might cause this behaviour?
>
>
>
>
>
> We have a Base role, which looks like this:
>
> "run_list": [
>
> ....
>
> "recipe[syslog-ng]",
>
> ....
>
> ]
>
>
>
> And a more specific role, OurSite which looks like:
>
> "run_list": [
>
> "role[Base]",
>
> ....
>
> "recipe[syslog-ng::prod-web]"
>
> ]
>
>
>
>
>
> The runlist for the node looks like:
>
> "run_list": [ "role[OurSite]" ]
>
>
>
>
>
> Now, I was expecting that the default "recipe[syslog-ng]" would be
>
> getting run quite early on.
>
> It has a "not_if" statement on a cookbook_file, which causes it to
>
> skip because we later want to use the syslog-ng::prod-web in this
>
> specific role.
>
>
>
> *BIZARRE THING*:
>
> The syslog-ng isn't run until the syslog-ng::prod-web recipe is supposed
>
> to run.
>
> I've verified this by moving syslog-ng::prod-web up and down in the
>
> run_list and watching the debug output in chef-client.
>
> And when the not_if kicks in, in the default recipe, the more specific
>
> syslog-ng::prod-web isn't even run.
>
>
>
> Help? I'm *guessing* this is happening because both recipes reference
>
> the same cookbook_file, but that doesn't explain why the run for the
>
> syslog-ng::default is delayed until much later, and why both recipes
>
> aren't run.
>
>
>
> I've included the pertinent bits of the recipes below.
>
>
>
>
>
> syslog-ng::default:
>
> cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
>
> not_if "grep 'SPECIAL CONFIG' /etc/syslog-ng/syslog-ng.conf"
>
> source "genericv2.conf"
>
> owner "root"
>
> group "root"
>
> mode 00644
>
> notifies :restart, resources(:service => "syslog-ng")
>
> end
>
>
>
> syslog-ng::prod-web
>
> cookbook_file "/etc/syslog-ng/syslog-ng.conf" do
>
> backup false
>
> source "prodweb-syslog-ng.conf"
>
> owner "root"
>
> group "root"
>
> mode 00644
>
> notifies :restart, resources(:service => "syslog-ng")
>
> end
>
>
>
--
Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E:
Archive powered by MHonArc 2.6.16.