I hope you are familiar with bash or C++‘s stream operator >>. If not, this post’s banner is not saying Chef is greater than Raspberry Pi, but rather, adding Chef to Raspberry Pi. In this post, I’ll do just that. I’m currently in a couple of job interviews in which some technical tasks are running on my 2 servers. To avoid disturbing the critical services running on those two machines, I decided to dust off me old Raspberry Pi and play with Chef there. I need these distractions in these dark times… 😒
Setting Up Raspberry Pi
First things first. Let us set up this little thing.
- I picked the official ubuntu-16.04 image for Raspberry Pi 2. For other Raspberry Pi version, check Ubuntu 16.04 LTS ‘classic’. Why I chose Ubuntu server image instead of Raspbian? Since all my other servers are Ubuntu servers. I want consistency!
- Prepare your Raspberry Pi’s SD card. I had a 32 GB one lying around, so I formatted it to NTFS using Ubuntu’s Disk Utility. Others prefer using GParted. Whatever works for you. For more information on this process, see Raspberry Pi’s Official Linux Instruction.
- Once SD card is formatted, we
xzcat ubuntu.img.xz | sudo dd bs=4M of=/dev/mmcblk0
- Plug it into your Raspberry Pi. Attach ethernet and power and wait.
- Discover your Raspberry Pi’s local IP address. This can be done by logging in to your router’s gateway and refer to your router’s documentation on the getting the list of connected machine.
- Finally ssh to your Raspberry Pi with username: ubuntu, password: ubuntu. It will ask you to change your password.
ssh ubuntu@<ip location> # Change <ip location> with your raspberry pi's ip.
Setting Up Ubuntu Server 16.04
This section will set up the installed Ubuntu Server.
- Like all new instance of Ubuntu Server, we update/upgrade,
sudo apt update && sudo apt upgrade
- Reboot to apply the upgrade,
sudo reboot
- Optional. Install your favorite text editor. As a follower of the church of GNU, praise be upon Richard Stallman, I naturally install emacs.
- Optional. I personally hate the “ubuntu” hostname, so I change it to my personal server naming convention linux-*. Since this is my third server, I want the hostname to be linux-03.
- Use your favorite editor to change /etc/hostname to your hostname. In my case, linux-03.
- Use your favorite editor to replace ubuntu in /etc/hosts to your desired hostname. Again, in my case, linux-03.
- Reboot.
- To avoid guessing the IP of your raspberry pi, it’s really useful to set up a static IP. Since this had been done more than a dozen times, here’s an official Ubuntu Network Configuration Documentation.
Installing Ruby
Now that our Ubuntu Server is looking like a proper server, let us install a Chef prerequisite, ruby.
- Download latest stable Ruby release. We can’t just use the usual apt install this time since those builds crashes. Trust me I tried…
# Replace with the latest stable ruby version. wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.gz
- Untar and get in there!
tar zxvf ruby-2.4.2.tar.gz cd ruby-2.4.2
- Configure with some unnecessary flags disabled.
./configure --enable-shared --disable-install-doc --disable-install-rdoc --disable-install-capi
- Compile and install. This’ll take a while…
make -j4 ; make install
- Log out / Log in to load new paths.
- Verify your ruby installation,
ruby -v
Install Chef-Client
Finally, we can install the chef-client:
- Use gem utility tool, ruby’s package management tool, to install Chef-Client:
gem install chef
- Verify your Chef-Client installation:
chef-client --version # Should display version.
I hope you find this guide useful. I won’t make heavy use of this like a Hadoop node. I’ll probably run some home security recipes, such as ZoneMinder.