CHEF and Raspberry Pi

Installing Chef Client on a Raspberry Pi 2 Model B

So you’re looking to manage a fleet of Raspberry Pi units with Chef but the omnibus installer doesn’t support ARM. What can you do?

Chef is a powerful automation platform that transforms complex infrastructure into code, bringing your servers and services to life. Whether you’re operating in the cloud, on-premises, or a hybrid, Chef automates how applications are configured, deployed, and managed across your network, no matter its size.

Why Use Chef with a Raspberry Pi?

The 2nd generation Raspberry Pi is a pretty impressive piece of hardware. They would make excellent development/qc servers, portable desktops, print servers, file servers, and even low traffic web servers. The small form factor and low power usage means they can be stuck just about anywhere there’s ethernet or WiFi and at only $35 each, this functionality comes as a steal.

Installing Ruby and Chef Gems

The first thing we need to do is purge the existing system version of Ruby. The Raspbian repository is grossly out of date and will only provide us with Ruby 1.9 while Chef requires >=2.0

sudo su -
apt-get update
apt-get purge ruby1.9 -y

Next we install our build dependencies. These may already be installed on your system, but it’s best to be sure.

apt-get install build-essential libyaml-dev libssl-dev

Now download the source code for your chosen version of Ruby. I use 2.2.2 in the example below.


Now untar and enter the Ruby source directory.

tar -xvzf ruby-2.2.2.tar.gz
cd ruby-2.2.2

Run the configure script to prepare for compiling.

./configure --enable-shared --disable-install-doc --disable-install-rdoc --disable-install-capi

Provided everything went well there, you’re now ready to compile. This will install Ruby to /usr/local/bin/ruby by default.

Update 2016-02-17: Thanks to a sharp eyed reader the following command has been updated to compile on all four cores of your RasPi 2

make -j4 ; make install

Go have a beer. This is going to take a while…

Hey hey! All done? Logout and log back in to ensure your path picks up the new Ruby. The rest is easy peasy.

sudo su -

Having relatively limited storage on the Raspberry Pi, I choose to not install all the gem documentation. Skip this next step if you prefer to have docs.

echo "gem: --no-document" >> ~/.gemrc

Now install the Chef Rubygem. Leave off the –no-ri and –no-rdoc if you want docs.

gem install chef --no-ri --no-rdoc

Now you’re cooking with Chef!

chef-client --version

Next Steps

If you’d like a great cookbook to manage the base configuration of your Pi, I created a fork of the Supermarket Raspberry-Pi cookbook on Github and added some of the new kernel features.

Happy Cooking!

10 thoughts on “Installing Chef Client on a Raspberry Pi 2 Model B”

  1. osmc@osmc:~$ gem install chef –no-ri –no-rdoc
    ERROR: Loading command: install (LoadError)
    cannot load such file — zlib
    ERROR: While executing gem … (NoMethodError)
    undefined method `invoke_with_build_args’ for nil:NilClass

    any Ideas?

  2. Thank you so much for this! I’m running a bunch of Beaglebone black boards and this is exactly what I needed. I actually ended up creating my own .deb file for the latest Ruby version so I could more quickly deploy to a bunch of boards. Compiling from source was soooo slow on these machines. Heh heh. But your guide was exactly what I needed to get on the right path. Thanks!

  3. Beautiful! Thank you so much for this post. It does take a long time to build. But if you use in the make command line -j4 it will use all 4 cores to compile. I broke your ‘make install’ line in

    make -j4 ; make install

  4. Hello,
    just tried on my raspberry pi 3 on raspbian 8 with ruby 2.3 and it works perfectly.
    Thanks a lot 🙂