This project generates and customizes a Raspberry Pi image, either for Ubuntu or Raspberry Pi OS. The script is built for running within a docker container.
The customizations include:
- Generating or adding a
vaultkey.secretfile - Updating Ansible configuration in
/boot/firmware/riasc.yaml - Updating cloud-init file in
/boot/firmware/user-data - Setting GIT Ansible repor in
/boot/firmware/riasc.yaml - Adding and enabling GIT based Ansible updates on reboot
- Switch to directory with Dockerfile to build image
docker build --tag "imagebuilder" .
- Create
envfile:
GIT_URL=https://mygiturl
FLAVOR=ubuntu22.04
GIT_BRANCH=mybranch
NODENAME=myhost
TAG=test
- Run docker container to generate image
docker run \
--volume ./:/tmp/riasc \
--volume ./out/:/tmp/data \
--env-file ./env \
imagebuilder
- Image is placed in ´out/output´ folder
- Copy image to SD card. Either using dd or the Raspberry Pi Imager
| Variable | Info | Default | OS |
|---|---|---|---|
| FLAVOR | Flavor of os. See list of flavors | - | All |
| NODENAME | The hostname of the device | - | All |
| TAG | A tag that is added to the name | - | All |
| RAW_OUTPOUT | Set to yes to get the .img file as output | - | All |
| VAULT_KEY | Key to use in the vaultkey.secret file | - | All |
| API_HOST | Hostname of API server | - | All |
| DEVICE_ID | UUID of this device | - | All |
| USERNAME | Set user for device | ubuntu | Ubuntu |
| PASSWORD | Set the password for the device | ubuntu | Ubuntu |
| FORCE_PW_CHANGE | Force use to change password on first login | true | Ubuntu |
ubuntu24.04
ubuntu22.04
ubuntu20.04
raspios
Check for the partitions in the image file:
fdisk -lu ubuntu-22.04.4-preinstalled-server-arm64+raspi.img
Run mount command. Make sure to update the offset (526336) for the correct value
mount ubuntu-22.04.4-preinstalled-server-arm64+raspi.img -o loop,offset=$(( 512 * 526336)) /mnt/
To use a custom secret the VAULT_KEY variable can be set. If a vaultkey file of the name NODENAME-vaultkey.secret already exists the variable will be ignored.
- Steffen Vogel 📧, Institute for Automation of Complex Power Systems, RWTH Aachen University
- Vincent Bareiß 📧, Institute for Automation of Complex Power Systems, RWTH Aachen University
- Manuel Pitz 📧, Institute for Automation of Complex Power Systems, RWTH Aachen University

of the H2020 Programme under Grant Agreement No. 870620