Simple qemu and ansible powered set of scripts to build and configure raspios images.
Scripts collection to modify the raspios image:
- mounts the image to perform some initial modifications
- boots on it using qemu
- runs ansible playbooks through qemu
- converts the qemu image back to .img format
- writes the image to the device/sdcard (using
dd
)
- ansible
- qemu
- ansible-role-security: source for the ssh and auto-updates tasks
- qemu-rpi-kernel: raspi kernel modified to boot on qemu (used for the online customization)
- raspberry linux kernel
- raspios
Full build: download latest media, apply changed, and flash to SD Card
Download latest media and requirement qemu kernel
Mount the .img and perform offline customizations to the OS:
- Enable ssh on boot
- Rename
pi
user to$IMAGE_USER
- Add public key located at
$SSH_PUBKEY
to$IMAGE_USER
's authorized keys
Convert .img file to qemu image
Boots the image on qemu
Runs $ANSIBLE_PLAYS
playbook list on the qemu booted image
Converts back qemu image to .img
Flashes $IMAGE_NAME
to $TARGET_DEVICE
Deletes all temporary and intermediate files
pimaker
configuration is performed through the environment variables in config.env
:
IMAGE_NAME
: name for the target .img file to createIMAGE_USER
: name of the main user to replace the stockpi
userIMAGE_SIZE
: size of the target device. If$TARGET_DEVICE
is defined then the size will be discovered automaticallySSH_PUBKEY
: path to the ssh public key to add to$IMAGE_USER
'sauthorized_keys
fileQEMU_SSH_PORT
: local port to map to qemu's port 22 (used foransible
to connect to the image and run playbooksTARGET_DEVICE
: path to the device on the host OS. If defined, will be used to find$IMAGE_SIZE
andpimaker
will flash the created img to this device usingdd