Build and deploy a custom Arch Linux image for Raspberry Pi 4.
- Ansible >= 2.10
- Packer >= 1.7.0
- Packer builder ARM plugin for Packer
# Required packages on Arch Linux host $ yay -S ansible packer qemu qemu-extra qemu-arch-extra qemu-user-static-binThe above packages are enough to build Packer images locally (commonly on Gnu/Linux). On MacOS, Windows 10 or when you just don't want to setup Packer and all the tools, Docker is also required:
- Docker >= 20.10
Pre-set packer sources available are:
- ArchLinux ARM armv7 (32-bit)
- ArchLinux ARM aarch64 (64-bit)
Open and edit the variables.pkrvars.hcl file to customize all the desired values.
Build the image using the latest available release:
$ sudo packer build -var-file="variables.pkrvars.hcl" packer/aarch64/When there's no native way to use qemu-user-static (MacOS or Windows 10) the image can be built using Docker:
$ docker run --rm --privileged \ -v /dev:/dev -v ${PWD}:/build \ packer-builder-arm build \ -var-file="variables.pkrvars.hcl" packer/aarch64/On Windows 10, the command above should be executed into a WSL2 console.
On GNU+Linux it's a very straightforward process:
# `/dev/sdX` is the device that represents your SD Card $ umount /dev/sdX* $ dd if=custom-rpi.img of=/dev/sdXAnother simple multiplatform tool to flash the image is Balena Etcher available for Windows 10, MacOS and GNU+Linux.
When done, put the SD Card into your Raspberry Pi 4 and Power On the device.
When your machine is up and ready, it should be accessible via SSH using the assigned static IP address (net_address variable), or using hostname.local where hostname is the assigned hostname.
$ ssh -i <path/to/id_rsa> alarm@192.168.0.1Install required collections and roles:
$ ansible-galaxy install -r requirements.ymlOpen and edit group_vars/*.yml files to customize the desired values. Once you have made the desired changes, let's configure the system via Ansible running the system.yml playbook:
$ ansible-playbook system.yml