I am learning Chef these days and I have been playing mostly with Chef Solo on a single virtual machine, trying various approaches and installing software using both the great Opscode cookbooks as well as some of the better community-contributed ones.

I have been following Jo Liss' excellent tutorial to get the Chef Ruby gem on my machine and then run my recipes. It uses the existing Ruby gems system to get Chef on the system which is a fine way to go about the problem, but there are other solutions too. For example, after getting through the docs I believe I found a simpler way to install everything -- the Omnibus installer that works on most operating systems and Linux distros out there. We should also mention that Opscode publishes a bunch of native packages for the most popular Linux distributions.

Installing as a Ruby Gem

Chef is written in Ruby and is primarily distributed as a Ruby gem. Ruby developers should feel at home with that system and on my Ubuntu VM, installation is as simple as getting the ruby1.9.1 package and installing the Chef gem:

apt-get install ruby1.9.1 ruby1.9.1-dev build-essential
gem1.9.1 install --no-ri --no-rdoc chef

The commands above install Ruby 1.9.1 and the build-essential package that may be needed for some Ruby C extensions. Then we go on to installing the latest Chef release (11.04 at the time of this writing).

You can also install a specific Chef version and run it on a different Ruby release, say the Ubuntu-default Ruby 1.8 (which I wouldn't recommend).

Pros:

  • As I already said, this is relatively simple to install and use. It should also be second nature to Ruby developers.
  • It uses the system-wide Ruby distribution and the binaries you'd rely on like chef-client and chef-solo get put on your path.
  • Your recipes being Ruby scripts can use any Ruby gem installed globally on the system.

Cons:

  • People that aren't comfortable with Ruby may find this hard or awkward.
  • It isn't integrated with your operating system's package manager. Ideally we'd have a Ubuntu package that I could install and upgrade with a single apt-get command.
  • Depending on the system Ruby has a dark side too. Installing a broken or noncompatible version of a Ruby gem might break your recipes.

Using the Omnibus Installer

The Omnibus installer is a full installation that has been packaged as an executable script. You just download it and run it on your server. Of course, you can do it with a single command run as root:

curl -L https://www.opscode.com/chef/install.sh | bash

That will download the latest version (you can use a specific version too) and install it along with all required dependencies. The installation will be placed in the /opt/chef folder and it will contain a full Ruby installation in /opt/chef/embedded

Pros:

  • By far, I believe this is the simplest and fastest way to install Chef on a server. I've been using it with great success.
  • The Chef installation uses its own isolated Ruby environment which reduces the chance of broken recipes due to botched gem installations.

Cons:

  • Again, this doesn't integrate with the OS/distro package manager and it could get hard or awkward when you try to install Chef with third party package management tools.
  • Installing a third-party gem that your recipes might use is harder. You'd need to use the /opt/chef/embedded/bin/gem command to get a new gem installed to that environment.

Using OS-specific Packages

The last option we'll discus uses the Opscode-published packages for various distributions and operating systems. Since I'm running a Ubuntu 12.04 VM, I'll refer you to the respective documentation. The process is pretty straightforward:

  1. Add the Opscode repository to your system.
  2. Fetch and trust the Opscode GPG key. Install the opscode-keyring package for auto-updates too.
  3. Finally install Chef: apt-get install chef

Pros:

  • Finally we have a package that installs with our distro's package manager and we can easily update it in the future.
  • We can set up the Chef package to be preinstalled on bare metal servers and VM's. For example, here's a guide on including the package with VM's built with Ubuntu's vm-builder tool.

Cons:

  • The installation is a bit complex. It would be great if we didn't have to work with GPG keys and just add a PPA. Or maybe have the chef packages bundled with Ubuntu.
  • It seems the Opscode repository doesn't contain a precise package for the recently-released Chef 11. I got a package containing Chef 10.18.

Conclusion

My Ubuntu-centric expedition in Chef-land is not over yet and I need to explore other operating systems too. I will be testing with CentOS in the next couple of days and I am most curious on how it all works on Windows. At the moment I'd say the Omnibus installer is a clear winner for me in terms of its simplicity and I'll keep using it.