- From: Sean OMeara <
>
- To:
- Subject: [chef] Re: Dynamically include recipes?
- Date: Mon, 10 Jan 2011 19:48:18 -0500
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=gR1S0VNOWHn8q5gFvPO50NZunabCy1g3G8DZbzs5QDLddSvezbPNwcnTbGb3Hqn9tC OEP47TLkMEKeUwal+Apbg0QrNHASDwifPXyGecMdUQTRaJEIfG6npLAM4ZO79HpKq8iK 1NOGyDE+LgsamhG1T31InLs+UfmqXkLsI+fTE=
Ian,
You can set arbitrary attributes on nodes within recipes.
so, you can do something like this:
name "appserver-config-a"
description "appserver-config-a"
run_list [
"recipe[fooservice::client]",
]
Then, in at the top of your cookbooks/fooservice/client.rb :
node.set[:fooservice][:client].
You can use that attribute from your nagios::server recipe to search for:
fooservice_clients = search(:node, "fooservice_client:true")
You have now effectively searched for nodes with the fooservice
cookbook installed.
-s
On Mon, Jan 10, 2011 at 5:58 PM, Ian Marlier
<
>
wrote:
>
Hi there, list --
>
>
I'm trying to figure out a way to do a (relatively) dynamic include_recipe
>
command. Specifically, the context of this question is a Nagios server, and
>
building the service definition files.
>
>
I would like to be able to do the following:
>
- Get a list of all cookbooks defined in the chef server
>
- For each cookbook C, see if that cookbook includes a recipe called
>
"nagios"
>
- If the cookbook does include a recipe called "nagios", then do
>
include_recipe "#{C}::nagios"
>
>
The idea is that when someone within my organization wants to add a chef
>
cookbook to install/configure a new service or a new application, they can
>
add the monitoring for that service/application as well -- without having to
>
alter the nagios cookbook.
>
>
I had sort of assumed that I could do this using search(), but it looks like
>
cookbooks/recipes aren't searchable. Sadness. So I'm wondering if anyone
>
has suggestions for other ways to make this happen.
>
>
(I know that one potential issue is the requirement that metadata.rb also be
>
updated. I'm not entirely sure how to deal with that, either. I figured I
>
would worry about one problem at a time...)
>
>
Thanks!
>
>
- Ian
>
Archive powered by MHonArc 2.6.16.