Raspberry Chef

22 Dec 2015

Python Tools git 

Originally posted at https://tech.labs.oliverwyman.com/blog/2015/12/22/raspberry-chef/

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. Run
    wget https://raw.githubusercontent.com/palfrey/raspberry-chef/master/bootstrap.sh
  4. Run
    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. Run
    sudo sh bootstrap.sh
  6. Run
    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:

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.

Previously: Pyrexia: IoT office temperature monitoring Next: Yet Another Jukebox