Installing chef on raspberry pi with centos

· by Artem Sidorenko · Read in about 2 min · (308 words)

Chef is building omnibus packages only for x86. But probably you want to run chef on raspberry pi 3 with ARM. There is a blogpost, which describes the chef installation on Raspbian. This blogpost covers the steps for chef installation on raspberry pi with centos.

Prepare the system

First of all, install centos on your raspberry pi.

Additionally I had to install ntpd in order to sync the clock:

$ yum install -y ntp
$ systemctl enable ntpdate ntpd
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/ntpdate.service.
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/ntpd.service.
$ systemctl start ntpdate ntpd

Install ruby

We install ruby from sources in order to have a modern ruby version, which is required by chef.

Install prerequisites for ruby compilation:

$ yum install -y gcc make zlib-devel openssl-devel

Install ruby 2.2 from sources:

$ mkdir /tmp/ruby
$ cd /tmp/ruby
$ curl -L --progress | tar xz
$ cd ruby-2.2.5
$ ./configure --prefix=/opt/ruby \
              --disable-install-doc \
              --disable-install-rdoc \
$ make -j4
# grab a coffee, it takes a while
$ make install
$ cd
$ rm -rf /tmp/ruby
# add ruby binaries to the PATH
$ echo 'export PATH="$PATH:/opt/ruby/bin"' > /etc/profile.d/
$ chmod +x /etc/profile.d/
$ source /etc/profile
# disable docs for all gem installations to save storage place
$ echo "gem: --no-ri --no-rdoc --no-document" > ~/.gemrc

Install chef

$ gem install chef
# run it:)
$ chef-client --version
Chef: 12.11.18

Ohai reports platform derived instead of centos:

$  ohai | grep platform
      "platform": "armv7l-linux-eabihf",
  "platform": "derived",
  "platform_version": null,

This would break the cookbooks, so lets fix it:

$ echo "CentOS Linux release 7.2.1511 (Core)" > /etc/redhat-release
$ ohai | grep platform
      "platform": "armv7l-linux-eabihf",
  "platform": "centos",
  "platform_version": "7.2.1511",
  "platform_family": "rhel",

See too