ansible, roam research, raspberry pi,

Restarting Projects: Ansible for the Win

Zach Zach Follow May 01, 2022 · 4 mins read
Restarting Projects: Ansible for the Win
Share this

We all know what it’s like to start a project and then have life intrude. A few months later when we try and pick it back up - we have no idea what we were doing and have to start over. This the story of learning to use Ansible and Roam Research to minimize project restart time.

Ansible is a handy tool that allows you to define what should be deployed to a host. My assumption was: if I start by automating all my steps via Ansible - it will be easy to know what’s been done as it will be in the code.

Roam Research was my collection point for useful docs, video’s, thoughts, and next steps for the project.

The Project: Raspberry Pi Kubernetes Cluster

As a nerd it is my standard approach to have way too many gadgets and an overly complex setup. Why have a single Wi-Fi router when you can have multiple access points wired into a POE switch that’s connected to your router right next to your rack mount Raspberry Pi’s. Naturally, you need to have multiple web interfaces to control everything (e.g. Unifi Controller, PiHole, Graphana). It’s possible to set those all up by hand - but where’s the fun in that? Let’s build a Kubernetes cluster out of the Raspberry Pi’s to host them all!

Since I’m a Kubernetes noob data collection is the first step. I’ve been using Roam Research for a few years as an external brain. (More on that later). My approach is simple - on my Daily Page create a block with the project name and start logging to do’s and any interesting links.

[[Setup Kubernetes Cluster]]
- walk through on how to build Kubernetes on pi: https://ubuntu.com/tutorials/how-to-kubernetes-cluster-on-raspberry-pi
- Run unifi controller on Kubernetes: https://flores.eken.nl/running-unifi-controller-on-k8s/
- getting started with ansible: https://youtube.com/watch?v=tq9sCeQNVYc&feature=share
- [ ] rebuild four raspberry pi’s
- [ ] create ansible script to prep the pi’s
- [ ] create ansible script to set some neovim defaults

Using the Daily Page for this is powerful as it lets me take notes quickly and my notes are automatically consolidated by Roam. When work on the project begins just create a new block on your Daily Page with the same project name and log what you need. To see a complete history of the project - put the project name in the search and Roam displays the summary.

Roam Project

Ansible to Prep the Raspberry Pi’s

Before diving into the Kubernetes side of the project I needed to learn Ansible. In grand Zach style this was the first “learning diversion” in the project. I quickly realized that Ansible could be used to standardize my terminal experience across all my computers (Mac’s, Raspberry Pi’s, Windows). Anytime standardization is an option - I lean into it. :D On the plus side this gave me an opportunity to dive deeper into Ansible.

A few suggestions:

  • Move from monolithic file to roles quickly
  • Take the time to understand priviledge escalation
  • Figure out how to debug playbooks

For a few weeks the most common activity was to flash a Pi and run a playbook. The approach was working! Between git log messages, notes in Roam, and executing a playbook to see / set the proper state - all the information needed was at my finger tips. Project restart time was less than five minutes. Removing the friction to restart gave me the power to get more work done through more frequent shorter engagements. Historically, I would need to find an hour or more to work - now progress could be made in as little as 20 minutes.

One day we had a power event at our house and four of my Pi’s had catastrophic failure on their boot drives. They all flipped to read-only and could not be coerced back to read-write. I was able to prep four new SD cards and use Ansible to return the Pi’s to a good state in ~10 minutes. It was an amazing feeling to be able to return to a good state that quickly.

This project was kicked off on February 12th 2022. In the last three months I’ve taken multiple breaks or gone down different learning paths and have been able to keep making progress by leveraging Ansible and Roam Research. I’m currently learning Kubernetes and having a blast.

If you want to checkout the Ansible roles I’ve built they are here.

Zach
Written by Zach
Leader, techie, blogger, love to explore new ideas and technology!