Thanks for the reply, but that’s a little bit different than what I’m trying
to do. I’m not actually interested (in this case) in a list of nodes with a
given cookbook installed.
Instead, what I’m interested in is a list of cookbooks that contain a
recipe with a given name, so that I can include all of those recipes. In
my use case, those recipes would define a nagios checkcommand and a nagios
What I had hoped to do was this:
cookbooks = search(:cookbooks, “recipe:nagios”)
cookbooks.each do |c|
However, the search function doesn’t appear to work on cookbooks. I’m
wondering if there’s another way that I can do this.
If there’s no way to do this within Chef, I can work around it, for example
by doing some bash scripting at cookbook upload time – though that would be
disappointing, as it would effectively make this recipe only operable in
certain chef server environments. If there’s a “real” way, that would be
On Mon, Jan 10, 2011 at 7:48 PM, Sean OMeara firstname.lastname@example.org wrote:
You can set arbitrary attributes on nodes within recipes.
so, you can do something like this:
Then, in at the top of your cookbooks/fooservice/client.rb :
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
On Mon, Jan 10, 2011 at 5:58 PM, Ian Marlier email@example.com
Hi there, list –
I’m trying to figure out a way to do a (relatively) dynamic
command. Specifically, the context of this question is a Nagios server,
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
- If the cookbook does include a recipe called “nagios”, then do
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
add the monitoring for that service/application as well – without having
alter the nagios cookbook.
I had sort of assumed that I could do this using search(), but it looks
cookbooks/recipes aren’t searchable. Sadness. So I’m wondering if
has suggestions for other ways to make this happen.
(I know that one potential issue is the requirement that metadata.rb also
updated. I’m not entirely sure how to deal with that, either. I figured
would worry about one problem at a time…)