An opinionated HashiCorp Packer template with integrated cloud-init to build 'cloud instances-like' images for Raspberry Pi
MIT License
An opinionated HashiCorp Packer template for Raspberry Pi images, built around the packer-builder-arm
ARM Packer builder plugin. It implements cloud-init for last-mile OS configuration and management.
See pi.pkr.hcl
.
Copy example.pkrvars.hcl
and edit.
(See Packer docs for more ways to set input variables)
(e.g. using usb-gadget/usb_gadget.pkrvars.hcl
)
docker run --rm --privileged \
-v /dev:/dev \
-v ${PWD}:/build \
mkaczanowski/packer-builder-arm \
build \
-var-file=usb-gadget/usb_gadget.pkrvars.hcl \
-var "git_repo=$(git remote get-url origin)" \
-var "git_commit=$(git rev-parse HEAD)" \
pi.pkr.hcl
(Using the above Docker image and run command is the easiest way to build cross-platform ARM images. See packer-builder-arm
for alternative ways to run Packer with the packer-builder-arm
plugin)
Name | Description | Type | Default | Required |
---|---|---|---|---|
boot_cmdline |
/boot/cmdline.txt config. Linux kernel boot parameters, as a list. Will be joined as a space-delimited string.e.g.:boot_cmdline = [ "abc", "def"]Will create /boot/cmdline.txt asabc def
|
list(string) |
[ "console=serial0,115200", "console=tty1", "root=/dev/mmcblk0p2", "rootfstype=ext4", "elevator=deadline", "fsck.repair=yes", "rootwait", "quiet", "init=/usr/lib/raspi-config/init_resize.sh"] | no |
boot_config |
/boot/config.txt Raspberry Pi system configuration, as a list. Will be joined by newlines.e.g.:boot_cmdline = [ "abc=123", "def=456"]Will begin /boot/config.txt with:abc=123def=456
|
list(string) |
[] |
no |
boot_config_filters |
/boot/config.txt Raspberry Pi system conditional filters configuration, as a list.e.g.:boot_config_filters = [ [ "[pi0]", "jhi=123", "klm=456" ], [ "[pi0w]", "xzy", "123" ],]Will end /boot/config.txt with:[pi0]jhi=123klm=456[pi0w]xyz123
|
list(list(string)) |
[ [ "[pi4]", "dtoverlay=vc4-fkms-v3d", "max_framebuffers=2" ]] | no |
cloudinit_metadata_file | The local path to a cloud-init metadata file. See the cloud-init NoCloud datasource
|
string |
n/a | yes |
cloudinit_userdata_file | The local path to a cloud-init userdata file. See the cloud-init NoCloud datasource
|
string |
n/a | yes |
file_checksum | The checksum value of file_url .See packer-builder-arm. |
string |
"" |
no |
file_checksum_type | The checksum type of file_checksum_url . See packer-builder-arm. |
string |
"sha256" |
no |
file_checksum_url | The checksum file URL of file_url . See packer-builder-arm. |
string |
"" |
no |
file_target_extension | The file extension of file_url . See packer-builder-arm. |
string |
"zip" |
no |
file_url | The URL of the OS image file. See packer-builder-arm. | string |
n/a | yes |
git_commit | The current git commit to pass to the build. It will be prepended to /boot/config.txt Use on the command-line, i.e. -var "git_commit=$(git rev-parse HEAD)"
|
string |
"" |
no |
git_repo | The current git remote to pass to the build. It will be prepended to /boot/config.txt Use on the command-line, i.e. -var "git_repo=$(git remote get-url origin)"
|
string |
"" |
no |
image_path | The file path the new OS image to create. | string |
n/a | yes |
kernel_modules | List of Linux kernel modules to enable, as seen in /etc/modules
|
list(string) |
[] |
no |
locales | List of locales to generate, as seen in /etc/locale.gen . |
list(string) |
[ "en_CA.UTF-8 UTF-8", "en_US.UTF-8 UTF-8"] | no |
wpa_supplicant_country | The ISO 3166-1 alpha-2 country code in which the device is operating. Required by the wpa_supplicant. | string |
"CA" |
no |
wpa_supplicant_enabled | Create a wpa_supplicant.conf file on the image. If wpa_supplicant_path exists, it will be copied to the OS image, otherwise a basic wpa_supplicant.conf file will be created using wpa_supplicant_ssid , wpa_supplicant_pass and wpa_supplicant_country . |
bool |
true |
no |
wpa_supplicant_pass | The WiFi password. | string |
"" |
no |
wpa_supplicant_path | The local path to existing wpa_supplicant.conf to copy to the image. |
string |
"/tmp/dummy" |
no |
wpa_supplicant_ssid | The WiFi SSID. | string |
"" |
no |