- From: Adam Jacob <
>
- To:
- Subject: [chef] Re: Re: Re: Passive recipes
- Date: Tue, 13 Oct 2009 14:30:08 -0700
On Tue, Oct 13, 2009 at 1:23 PM, Dan DeMaggio
<
>
wrote:
>
> This also means that you couldn't use the apache cookbook
>
> on a system which didn't have the collectd cookbook.
>
>
Exactly, but I want my recipes to be modular.
My instinct is to put this stuff in a collectd cookbook, rather than
have the apache cookbook embed collectd resources.
>
> 2) Check the node's variables in the collectd config templates and only
>
> enable the config you need.
>
> <% if @node[:mysql] -%>
>
>
The problem is that you have no idea if the MySQL recipe is called or
>
not .. You only have the attributes, which are always defined. So you
>
will always copy the collectd-mysql config file, even if MySQL is not
>
going to be installed.
>
>
> Would love to have a better solution to this problem.
>
>
Looks like light weight resources/providers might help, but I'm still
>
trying to wrap my head around them.
I would set a node attribute in the recipe itself, in an innocuous
enough namespace, and then use that attribute in the
collectd/munin/etc recipes see what should be configured.
Essentially, you're sending a message to yourself, saying "please
monitor/trend this".
Something like:
###
# Apache Recipe
###
node.set[:monitor][:apache2] = true
###
# Collectd Recipe
###
if node[:monitor][:apache2]
... do some stuff to enable ...
else
... do some stuff to disable ...
end
if node[:monitor][:mysql]
... do some stuff ...
end
####
The basic gist is, if the recipe is applied, then you should monitor
it. You can also do this:
if node.recipe?('apache2')
end
And avoid setting an attribute altogether.
In either case, you'll want to make sure that the collectd recipe
comes last in the run list.
Adam
--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E:
Archive powered by MHonArc 2.6.16.