Packer, Ansible and DietPi for my Raspberry PIs
This is an update to Automatically build Raspberry PIs using Ansible and Packer Image Building for RaspiOS Bookworm. The idea is the same: Packer builds an SD card image, Ansible puts wifi, SSH key, password and Tinc VPN for one specific PI into it, and the secrets are in Ansible Vault. What changed is the Packer builder and, for one Pi Zero 2 W, the operating system.
Switching the Packer builder
At the end of 2023, Packer 1.10 in packer-builder-arm broke the Ansible provisioner. I pinned the last working Docker image for almost two years. For a newer RaspiOS (Trixie) I switched to packer-plugin-cross, which comes as a ready Docker image. The configs are in HCL now.
Ansible runs inside the image now: Packer installs ansible-core in QEMU, runs the playbook with ansible-local and removes Ansible again.
DietPi on a Pi Zero 2 W
The Pi Zero 2 W has only 512MB of memory, so I tried DietPi.
I first used the 32-bit image, but Hermes Agent does not install on 32-bit.
The Pi has a 64-bit CPU, so I switched to the current 64-bit one: DietPi_RPi234-ARMv8-Trixie.
DietPi applies most settings from /boot/dietpi.txt on the first boot, so the playbook only fills that file and /boot/dietpi-wifi.txt.
The SSH key is added to root and dietpi.
Hermes Agent is a bit much for the Pi Zero 2 W.
For encrypted Matrix it compiles python-olm on the Pi, which the Zero 2 W is absolutely not suited for.
With its web dashboard running the Pi swaps and answers very slowly, so I turned the dashboard off.
So currently Hermes is only answering via Matrix.
On my other old Pi Zeros I have not switched away from 32-bit RaspiOS yet, but I will when they need an update. Everything is in the same repository as before.
Pushing to Forgejo from DietPi
DietPi uses Dropbear instead of OpenSSH, so there is no ssh and no ssh-keygen on the Pi.
The client is dbclient and keys are generated with dropbearkey:
dropbearkey writes the private key in its own format and only prints the public key, there is no .pub file.
I added the public key as a deploy key with write access to the repository in Forgejo.
dbclient does not read ~/.ssh/config and git calls ssh by default, which fails with cannot run ssh: No such file or directory.
Setting core.sshCommand in the repository fixes that: