Too Hot in the Machine Room? Try Chef.

If you manage a system, you need Chef. Here are some of the best Chef resources and cookbooks on Github.

Every great system administrator maintains a bag of tricks: the Perl script to obliterate a user’s account on every system; the Bash script to setup a new server in minutes instead of hours; the Python script to alert a naughty user that has exceeded her print quota. Indeed, the vast array of languages and techniques used to keep machines up and running is astounding to behold. (Witness the diversity on Github alone.)

But as systems get bigger and proliferate in number, using random scripts becomes problematic. “Wait, did I run that script on sy001-04? Or sy004-01? And which system is next?” That’s where new projects like Chef come in.

Chef manages a large number of systems via a collection of “recipes,” or code to define a configuration. Writing code to manage configuration seems backwards at first, but its advantages quickly become apparent if you consider the possibilities of the approach.

For example, say you’re creating a web account for a new user. A Chef recipe can fetch some data from an LDAP system, transform it, and either write a specific .htaccess entry or configure Apache to treat the user’s new home directory as a webroot.

Chef recipes are plain Ruby code, letting you reuse existing Ruby libraries, language techniques, and other integration scripts. Writing a Chef recipe isn’t really difficult at all. The Opscode website explains the process in detail and offers plenty of advice on configuration, administration, and “cooking” solutions.

Here, in this installment of “This Week on Github,” I’m going to point out a few of the best Chef resources and cookbooks on Github.

Installing Chef

Chef requires a lot of external dependencies, most of which are very easy to install. However, if you find yourself struggling a bit and happen to be running Gentoo or a close derivative, you might be interested in Caleb Tennis’s portage overlay for Chef available at http://github.com/ctennis/chef-overlay. Simply clone the repository, add it as an overlay in make.conf, and away you go! (If you’re not running on Gentoo, Opscode has great instructions on their website about getting Chef installed on other systems.)

Sous Chef

One tool to jump start your cooking is the sous-chef project from Ben Burkert. This applications generates the files required to deploy and manage a Rails or Merb stack using Chef.

For example, to setup an application with a cookbook (a collection of recipes) and a single node (i.e., a machine to manage), you simply run a few commands:

$ chefify .
Generating with app generator:
      [ADDED]  config
      [ADDED]  nodes
      [ADDED]  cookbooks
      [ADDED]  config/sous-chef.yml
      [ADDED]  Rakefile
$ chef-gen cookbook production --environment=production --platform=ec2
  Generating with cookbook generator:
      [ADDED]  cookbooks/postgresql/attributes/server.rb
      [ADDED]  cookbooks/postgresql/recipes/server.rb
$ chef-gen node production --environment=production --platform=ec2
Generating with node generator:
      [ADDED]  nodes/beta/cookbooks/system/attributes
      [ADDED]  nodes/beta/cookbooks/beta/recipes/default.rb
      [ADDED]  nodes/beta/cookbooks/beta/attributes/beta_node.rb

To deploy using this setup, just run the chef script:

$ chef production:deploy
$ chef production:test

The generators aren’t useful for everyone (for example, if you’re deploying PHP or Java apps), but most serve to bootstrap environments.

Creatures of (Perl) Habit

Can’t seem to kick that Perl habit? No problem. Adam Jacob has come to the rescue with chef-perl, a tool to let you write Chef recipes in Perl.

For example, you can use Perl to create a new Apache configuration file:


use Chef;

resource file => '/etc/http.conf', sub {
  my $r = shift;


chef-perl supports most basic recipe operations, but it doesn’t yet support creating other types of files for use with Chef.

Casserole, Anyone?

If you run Mac OS X and use Chef, check out Casserole from fotonauts. Casserole is a GUI for Chef that allows you to explore nodes and cookbooks, access your search indexes, and filter search results. As of this writing, the tool is limited to read-only access of Chef nodes, but write access is on its way in a near future release.

Make Mine the Drive-thru

If you don’t want to hassle with cooking but want to deploy a Web application and manage a server or two, try drive-thru, written by Mike Hale. The drive-thru project) is a dead-simple way to setup your app for deployment.

The bulk of work in drive-thru happens in dna.rb. For instance, a standard Apache setup looks something like this:

dna = {
  :apps_dir => "/var/www/data/apps",
  :applications => [
      :name => "myapp",
      :server_name => "myapp.com",
      :server_aliases => ["www.myapp.com", "production.myapp.com"],
  :recipes => [
    "apache2", "apache2::mod_rails",

Edit a few more chef-related files, and you’re rolling on Apache and Passenger in no time! You could tweak these files to setup for other languages or web servers.

The Joy of Cooking

Once you know you’re way around the kitchen, check out a few cookbooks available from Github users.

  • Opscode, the creators of Chef, have posted a rather comprehensive collection of recipes on their Github account at http://github.com/opscode/cookbooks. There’s a recipe for nearly everything: Django, Erlang, Ruby, setting up a Ubuntu box, a Rails stack, Postfix, PHP, JIRA, Munin, Apache, and even CouchDB. This repository is both a reference and a great place to cargo cult some recipes.
  • The folks at 37signals have shared a few more recipes not available in the Opscode repository at http://github.com/37signals/37s_cookbooks. My favorite additions include the Nagios recipe and the recipe for handling SSH keys.
  • Josh Sierles, a systems adminstraator at 37signals, has also shared his cookbook for installing Asterisk (everyone’s favorite open source VoIP solution) at http://github.com/jsierles/asterisk-chef. I hear it works great.

See you next week! Remember, if you’ve got something cool you want to share, ping me on Github at jeremymcanally or via Twitter at @jm.

Comments on "Too Hot in the Machine Room? Try Chef."

Very handful of internet sites that come about to become detailed below, from our point of view are undoubtedly effectively worth checking out.

Here are some hyperlinks to sites that we link to for the reason that we feel they’re really worth visiting.

Here is a great Weblog You may Obtain Interesting that we encourage you to visit.

We like to honor several other world wide web web sites around the web, even if they aren?t linked to us, by linking to them. Underneath are some webpages worth checking out.

Usually posts some incredibly interesting stuff like this. If you are new to this site.

Leave a Reply