2 min read

Chef (the DevOps kind, not the shouty restaurant kind)

When I started looking at the new wave of DevOps, I sort of just picked Puppet. A few respected people in the Drupal world were already using it and it wasn’t ruby. So easy win right?

We use Puppet at Demotix and really like it. But I recently wanted to see how the other half lives, so tried to do a simple Drupal stack using Chef.

Here are my basic notes on that process, I hope to do some more analysis later.

Anyway, onto the notes/tutorial/thing.

Jump past the tutorial to see how to install the bits your going to need.


I want to create a simple LAMP server and install Drupal Commerce Kickstart (https://drupal.org/project/commerce_kickstart).

To do this you will need :

  • Chef
  • Chef-solo
  • Berkshelf
  • Server (or VM) installed with Ubuntu to install onto.

Step 1: Create a solo kitchen
knife solo init tutorial

Step 2: Download my probably very badly made cookbook for this
cd tutorial/site-cookbooks;
curl -L https://github.com/a-c-m/chef-drupal-kickstart-lamp/archive/master.zip | tar zx
mv chef-drupal-kickstart-lamp-master chef-drupal-kickstart-lamp

Step 3: Let Berkshelf download the dependencies, into the cookbooks folder
cd chef-drupal-kickstart-lamp
berks install --path ../../cookbooks/
(this will install a lot of files into the cookbooks directory)

Step 4: Prepare the target server
cd ../../
knife solo prepare <ip>
(this will create a file in nodes, which describes your node)

Step 5: Set up the node to run the recipe
Edit with a tool of your choice the nodes/.json and make it look something like :
"mysql": {
"server_root_password": "ChangeMelikeRIGHTNOW",
"server_repl_password": "ChangeMelikeRIGHTNOW",
"server_debian_password": "ChangeMelikeRIGHTNOW"
"run_list":["recipe[apt]", "recipe[chef-drupal-kickstart-lamp]"]

Your setting up your mysql passwords and then asking chef to run apt (so its up to date), then run the main recipe.

Step 5: Start cooking (run the code)
knife solo cook <ip>

Step 6: Done, go try out the new site

Tadaaaaa !

BEST QUICKSTART / TUTORIAL (other than this one)




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


Running Chef without having a central server. These little set of tools makes that simpler.

gem install knife-solo

I think there is more than one way to skin this cat, but this is the one I found.

There is also some interesting stuff using solo with Capistrano.


A script to auto download and manage your dependent “cook books”.

gem install librarian-chef

Then in the working dir run

librarian-chef init

Which will create you a Cheffile, which will have a bunch of commented out lines. Comment them back in (some you might not need) and then run

librarian-chef install

Which will go off and install your Dependant books. Smart!



Same idea as Librarian, except it does it a bit better by all accounts, it installs the dependencies to a shared location, instead of per module, also some some other smart things I’ve not worked out yet.

Installed via the gem

gem install berkshelf

It stores its dependencies in Berksfile.

By default when you

berks install

it installs them into your home directory, which means if your using solo (like we are), you need to force it to install to a local folder e.g.

berks install --path ../../cookbooks/


undefined method[]’ for nil:NilClassanduninitialized constant Chef::Recipe::Opscode`

Basically, newer versions of Chef need you to load in defaults via the metadata.rb Thanks to : http://stackoverflow.com/questions/17391644/default-attribute-is-nil-for-chef-apache2-cookbook