Raspberry Chef

By: on December 22, 2015

Last month I wrote about temperature monitoring, and how I ended up using Raspberry Pi’s. I’m still fiddling around with their configuration, and I ran into a few problems. For starters, if I brought them home, they knew how to talk to the work WiFi, but not my home system, and vice versa (although this is fixable with a more complicated wpa_supplicant configuration). Secondly, keeping the various nodes in sync with each other’s config was getting annoying, and unfortunately state-of-the art in most Raspberry Pi work appears to be “get everything perfect, then copy the SD card”, which really isn’t suitable. I’ve therefore come up with something a little bit more usable, which also let me test out something else I’ve been meaning to play with for a while.

We use a variety of different configuration management systems for different client projects (Chef, Puppet, Salt, Ansible, etc, etc), and the standard configuration for most of them is a centralised server that provides information to the client nodes. However, you can do a more decentralised option, provided the nodes still know where to get updated information from. Enter Raspberry Chef, a little daemon primarily targeted towards Raspberry Pis (although it’d work fine on quite a lot of other systems). How it works is that it automatically pulls data from git (probably a github project) on a regular basis, and then runs chef-client in a chef-zero configuration using the data from git.

To build your own node, do the following:

  1. Write a Debian-based image to the SD card for your Pi (I advise the Jessie Lite image as a good small base)
  2. Plug it into ethernet, boot it up and SSH into the node (possibly just
    ssh pi@raspberrypi

    with password “raspberry” if you’re using the defaults)

  3. wget https://raw.githubusercontent.com/palfrey/raspberry-chef/master/bootstrap.sh
  4. cat bootstrap.sh
    • Read the contents of bootstrap.sh and make sure you understand it before just randomly running something I told you to.
  5. sudo sh bootstrap.sh
  6. sudo poweroff

You’ve now got an auto-updating SD card, which you can backup and re-use for other nodes. To configure it, there’s a series of files in /boot which is a FAT32 partition, which means it’ll get mounted on Linux, OS X or Windows which means you can configure it without needing a running and connected Pi.

The following files in /boot are of particular use:

  • wifi.conf

    – a wpa_supplicant configuration file which will work in combination with a USB WiFi adaptor. For simple configs, the changes should be obvious, but for more complicated settings see the example config

  • chef-url

    – a git URL to clone that contains Chef cookbooks

  • chef-cookbook

    – Chef cookbook from the chef-url path to run with chef-client

The update_chef daemon will automatically check chef-url/chef-cookbook and run chef-client on a regular basis in chef-zero configuration if it finds a valid set of configuration.

Share

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*