Skip to content

Latest commit

 

History

History
90 lines (63 loc) · 3.17 KB

README.md

File metadata and controls

90 lines (63 loc) · 3.17 KB

Raspberry PI Image generation

This project generates and customizes a Raspberry Pi image, either for Ubuntu or Raspberry Pi OS. The script is build for running within a docker container.

The customizations include:

  • Generating or adding a vaultkey.secret file
  • 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

Usage

  1. Switch to direcory with Dockerfile to build image
docker build --tag "imagebuilder" .
  1. Create env file:
GIT_URL=https://mygiturl
FLAVOR=ubuntu22.04
GIT_BRANCH=mybranch
NODENAME=myhost
TAG=test
  1. Run docker container to generate image
docker run \
--volume ./:/tmp/riasc \
--volume ./out/:/tmp/data \
--env-file ./env \
imagebuilder
  1. Image is placed in ´out/output´ folder
  2. Copy image to SD card. Either using dd or the Raspberry Pi Imiger

List of available variables

Variable Info
GIT_URL URL to ansible git repository
FLAVOR Falvor of os. See list of flavors
GIT_BRANCH Branch used in ansible git pull
NODENAME The hostname of the device
TAG A tag that is added to the name
RAW_OUTPOUT Set to yes to get the .img file as output
TOKEN A token used by Ansible
VAULT_KEY Key to use in the vaultkey.secret file

List of flavors

ubuntu24.04

ubuntu22.04

ubuntu20.04

raspios

Help

How to mount the generated image to check the content?

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/

How to add my custom secrets file for ansible vaults?

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.

GitHub

Credits

Funding acknowledment

European Flag The development of RIasC has been supported by the ERIGrid 2.0 project
of the H2020 Programme under Grant Agreement No. 870620