Tuesday, April 19, 2016

Introduction

So you’ve got 1,103 Raspberry Pis that you need to manage. Two things:

Why?

Wanna hang out Saturday? No? You’re busy managing all your mini computers manually? I can help you with that!

Scope

In this article we’ll cover installing and configuring the Chef version 12 client on a Raspberry Pi. This has been tested on Raspberry Pi versions 2 and 3; in theory it should work on a 1 as well, albeit slowly.

Assumptions

Raspberry Pi with Rasbian, Hypriot, or similar build with connections to interwebs

Chef server/org you would like to point clients to

Chef workstation capable of bootstrapping clients; if needed see this excellent article by Digital Ocean.

Execution

The main point of this article is really the installation of Ruby, which is the foundation on which Chef is based. Because the Ruby package in the Rasbian locations is out of date (2.1 as of this writing) we need to compile our own from source. Chef 12 requires Ruby 2.0 or greater, but Rack, which is installed with Chef, requires 2.2.2. UPDATE 7/9/2017: Ruby 2.4 or newer is now needed to continue successfully. Thanks Mike (from comments below)!

Step 1: Install Ruby

Clearly this should be scripted for optimal efficiency, but for learning purposes we’ll do it step by step to see exactly what is going on first hand. Log onto your Raspi via SSH and execute the following:

Step 2: Install Chef

Note: This will take between 5 and 25 minutes depending on which Pi, SD card, and network connection.

Relinquish root privileges as they are no longer needed. This should only exit the root session and not the SSH session itself. If you’re logged in directly as root ignore this, but don’t do that next time!

exit

Test the install to ensure it worked

chef-client --version

Step 3: Configure Chef

For this step move to your Chef workstation and logon using your account that is configured to manage your organization.

Where: {user} is a user on the target platform with root privs and {password} is the password for that account.

Note: It is normal to see errors on the first portion on the bootstrap since the Chef ARM client will not be found in the Chef repo, but the second phase should work utilizing the client we just installed.

That’s it! For further verification you can check against the Chef server using your workstation (knife client show {node name}) or even better yet, use Chef Manage if you have it available.