Building Chef 15.0.300 for CentOS, Debian and Raspbian on 32-bit ARM

Chef

Chef 15 has been released and there are already newer releases available (15.0.298 and 15.0.300). The build instructions have not changed substantially from Chef 14 for Debian/Raspbian 9 or from CentOS 7, so I’m consolidating them into a single document.

Chef 15 requires acceptance of Chef’s license, but these builds are still considered officially unsupported by Chef.

Overview

The Chef client is packaged with Omnibus, which builds the application and all of its runtime dependencies with the Omnibus-Toolchain. Omnibus is built with Ruby, so the instructions need to start with building Ruby. These instructions assume you have already installed either Debian 9, Raspbian 9, or CentOS 7 on you system already.

Preparation

There are several steps that need to be done before we get started. As the root user update to ensure the latest packages are installed and install the prerequisites for building Ruby and Omnibus-Toolchain.

For CentOS:

yum update
yum install -y autoconf automake bison flex gcc gcc-c++ gdbm-devel gettext git kernel-devel libffi-devel libyaml-devel m4 make ncurses-devel openssl-devel patch readline-devel rpm-build wget zlib-devel

For Debian/Raspbian:

apt-get update
apt-get upgrade
apt-get install -y autoconf fakeroot git libreadline-dev libssl-dev zlib1g-dev

Add the omnibus user for performing the builds.

useradd omnibus

Ensure the omnibus user has sudo privileges and add the following file to /etc/sudoers.d/omnibus. Feel free to use the wheel group or more limited permissions as necessary.

omnibus  ALL=(ALL)       NOPASSWD: ALL

You can now sudo su - omnibus and continue without changing users.

Previous Installations

If you have previously-installed Chef and omnibus-toolchain packages (perhaps following these instructions), you’ll need to uninstall those and clear out the directories.

sudo systemctl stop chef-client
sudo yum remove chef omnibus-toolchain -y # CentOS
sudo apt-get remove chef omnibus-toolchain -y # Debian/Raspbian
sudo rm -rf /opt/chef /opt/omnibus-toolchain

Ruby 2.6.3

The Omnibus-toolchain is built with Ruby 2.6.3, so we will install it with rbenv. We don’t need documentation for our gems, so first we’ll disable that.

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

Let’s install rbenv and add it to our PATH.

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Install the ruby-build plugin to make it easier to manage different Ruby versions.

mkdir plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 2.6.3
rbenv global 2.6.3
eval "$(rbenv init -)"

Omnibus CentOS Raspberry Pi 3 Patch

CentOS provides packages for the Raspberry Pi 3 platform, but the arch is armv7hl not armv7l. Omnibus does not have proper support for this yet, but the following patch has been submitted. You will need to patch your lib/omnibus/packagers/rpm.rb in your omnibus gem provided by bundler accordingly.

Omnibus-Toolchain

Now that Ruby is installed, let’s build and install the Omnibus-Toolchain as the omnibus user.

cd
git clone https://github.com/chef/omnibus-toolchain.git
cd omnibus-toolchain
bundle install --without development --path=.bundle

Apply the lib/omnibus/packagers/rpm.rb patch to

~/omnibus-toolchain/.bundle/ruby/2.6.0/bundler/gems/omnibus-*/lib/omnibus/packagers/rpm.rb

Now you can build and install the package.

sudo mkdir /opt/omnibus-toolchain
sudo mkdir /var/cache/omnibus
sudo chown omnibus:omnibus -R /opt/omnibus-toolchain
sudo chown omnibus:omnibus -R /var/cache/omnibus
bundle exec omnibus build omnibus-toolchain -l internal
sudo rm -rf /opt/omnibus-toolchain
sudo rpm -Uvh ~/omnibus-toolchain/pkg/omnibus-toolchain*el7.armv7hl.rpm # CentOS
sudo dpkg -i ~/omnibus-toolchain/pkg/omnibus-toolchain*deb # Debian/Raspbian

Chef 15.0.300

With omnibus-toolchain installed, we can reset our PATH and build Chef as the omnibus user.

cd
export PATH="/opt/omnibus-toolchain/bin:$PATH"
wget https://github.com/chef/chef/archive/v15.0.300.tar.gz
tar -xzf v15.0.300.tar.gz
cd chef-15.0.300/omnibus/
bundle install --without development --path=.bundle

Apply the lib/omnibus/packagers/rpm.rb patch to

 ~/chef-15.0.300/omnibus/.bundle/ruby/2.6.0/bundler/gems/omnibus-*/lib/omnibus/packagers/rpm.rb

Now you can complete the Chef build.

sudo mkdir /opt/chef
sudo chown omnibus:omnibus -R /opt/chef
bundle exec omnibus build chef -l internal

This may take 1-4 hours depending on which ARM machine you are using.

Installing Chef 15.0.300

Once the builds have completed we can delete the working build directory.

sudo rm -rf /opt/chef

Now Chef 15.0.300 can be installed on CentOS:

sudo rpm -Uvh ~/chef-15.0.300/omnibus/pkg/chef_15.0.300*el7.armv7hl.rpm

or on Debian/Raspbian:

sudo dpkg -i ~/chef-15.0.300/omnibus/pkg/chef_15.0.300*armhf.deb

Using the new Chef build

From your workstation, you can now knife bootstrap the machine with the ARM build on it and register it with your Chef Server. If you are working with a previously Chef-managed box, you can run chef-client and the machine will continue to use its previous configuration.

Build Scripts

Once you’ve gone through the installation steps a few times, you’ll probably want a single script you can run to build new releases. Here are the current scripts I run as the omnibus user::

  • CentOS: chef-15.0.300-RPM.sh and run nohup sh chef-15.0.300-RPM.sh > chef-15.0.300-RPM.sh.log &
  • Debian/Raspbian: chef-15.0.300-DEB.sh and run nohup sh chef-15.0.300-DEB.sh > chef-15.0.300-DEB.sh.log &

And tail -f the output.

Chef 15.0.300 CentOS 7 Raspberry Pi 3 DEB and RPM Packages