[chef] Re: Passive recipes


Chronological Thread 
  • From: Garret Heaton < >
  • To:
  • Subject: [chef] Re: Passive recipes
  • Date: Wed, 7 Oct 2009 15:04:53 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=qG53dxuJSajrytKa+pmQ3M7bB9KYCoP6NW3PKRmZU9retQVyl/Pecq3dhK8JsOzCc0 EqDxFntPSPiNODK2CB7HmO+xu6MeW30LVljC4u0tRoLQu4brwGS+pIhWEorCZHOv0LtX tiIcNQjqSG7ZmGNcob9Pt0pDFqs6Me1gmdD4U=

I've solved this problem in two different ways, and wasn't really happy with either. They are;

1) Define a library function in the collectd cookbook which you can use in other cookbooks' recipes. This is how the 37signals monit cookbook works, and probably wouldn't work well with collectd because it expects all its config to be in a single file (I think). This also means that you couldn't use the apache cookbook on a system which didn't have the collectd cookbook.

2) Check the node's variables in the collectd config templates and only enable the config you need. I have the following in my collectd/templates/default/collectd.conf.erb:

<% if @node[:mysql] -%>
LoadPlugin mysql
<Plugin mysql>
  Host localhost
  User "root"
  Password "<%= @node[:mysql][:server_root_password] %>"
  Database "yourdb"
</Plugin>
<% end -%>

I'm not sure if this would work if I were installing collectd and mysql on a new box at the same time.

Would love to have a better solution to this problem.

- Garret

On Wed, Oct 7, 2009 at 11:31 AM, < "> > wrote:
Is there a way to have recipes that are activated based on the activation
status of other recipes?

For example, if Apache is installed and Collectd is installed, then I want to
run the "apache-collectd" recipe.  But I don't want to force either Apache or
Collectd to be installed, and I don't want one servers' recipe to depend on the
other.

Ideally, the two server recipes would have no knowledge of the other, and the
apache-collectd module would know about both. How to do this without forcing
anything to be installed on all servers?

During recipe runtime, the list of recipes is still being built, so I can't
trigger a single resource when both are present.  At resource execution
(convergence), I know all the recipes, but it's unclear how you get a resource
in the right place.

There might be a way to do this with scripts on the server, but that's not a
general solution (and how do I make sure that the script is run after Apache
and Collectd resources are finished?).

-=Dan=-




Archive powered by MHonArc 2.6.16.

§