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.
exit 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!
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.