Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pndurette/pi-packer
An opinionated HashiCorp Packer template with integrated cloud-init to build 'cloud instances-like' images for Raspberry Pi
https://github.com/pndurette/pi-packer
cloud cloud-init packer packer-template raspberry-pi raspberrypi
Last synced: about 2 months ago
JSON representation
An opinionated HashiCorp Packer template with integrated cloud-init to build 'cloud instances-like' images for Raspberry Pi
- Host: GitHub
- URL: https://github.com/pndurette/pi-packer
- Owner: pndurette
- License: mit
- Created: 2021-07-05T03:33:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-25T16:29:28.000Z (over 1 year ago)
- Last Synced: 2024-11-01T02:34:44.839Z (2 months ago)
- Topics: cloud, cloud-init, packer, packer-template, raspberry-pi, raspberrypi
- Language: HCL
- Homepage:
- Size: 36.1 KB
- Stars: 26
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pi-packer
An opinionated [HashiCorp Packer](https://www.packer.io) template for Raspberry Pi images, built around the [`packer-builder-arm`](https://github.com/mkaczanowski/packer-builder-arm) ARM Packer builder plugin. It implements [cloud-init](https://cloudinit.readthedocs.io/en/latest/index.html) for last-mile OS configuration and management.
See [`pi.pkr.hcl`](pi.pkr.hcl).
## Usage
### 1. Configuration values
Copy [`example.pkrvars.hcl`](example.pkrvars.hcl) and edit.
*(See [Packer docs](https://www.packer.io/docs/templates/hcl_templates/variables#assigning-values-to-build-variables) for more ways to set input variables)*
### 2. Build
(e.g. using [`usb-gadget/usb_gadget.pkrvars.hcl`](usb-gadget/usb\_gadget.pkrvars.hcl))
```bash
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`](https://github.com/mkaczanowski/packer-builder-arm#quick-start) for alternative ways to run Packer with the `packer-builder-arm` plugin)*## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [boot\_cmdline](#input\_boot\_cmdline) | [`/boot/cmdline.txt`](https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md) config.
Linux kernel boot parameters, as a list. Will be joined as a space-delimited string.
e.g.:boot_cmdline = [Will create `/boot/cmdline.txt` as
"abc",
"def"
]abc def| `list(string)` |[| no |
"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"
]
| [boot\_config](#input\_boot\_config) | [`/boot/config.txt`](https://www.raspberrypi.org/documentation/configuration/config-txt/README.md)
Raspberry Pi system configuration, as a list. Will be joined by newlines.
e.g.:boot_cmdline = [Will begin `/boot/config.txt` with:
"abc=123",
"def=456"
]abc=123| `list(string)` | `[]` | no |
def=456
| [boot\_config\_filters](#input\_boot\_config\_filters) | [`/boot/config.txt`](ttps://www.raspberrypi.org/documentation/configuration/config-txt/conditional.md)
Raspberry Pi system *conditional filters* configuration, as a list.
e.g.:boot_config_filters = [Will end `/boot/config.txt` with:
[
"[pi0]",
"jhi=123",
"klm=456"
],
[
"[pi0w]",
"xzy",
"123"
],
][pi0]| `list(list(string))` |
jhi=123
klm=456
[pi0w]
xyz
123[| no |
[
"[pi4]",
"dtoverlay=vc4-fkms-v3d",
"max_framebuffers=2"
]
]
| [cloudinit\_metadata\_file](#input\_cloudinit\_metadata\_file) | The local path to a cloud-init metadata file.
See the `cloud-init` [`NoCloud` datasource](https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html) | `string` | n/a | yes |
| [cloudinit\_userdata\_file](#input\_cloudinit\_userdata\_file) | The local path to a cloud-init userdata file.
See the `cloud-init` [`NoCloud` datasource](https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html) | `string` | n/a | yes |
| [file\_checksum](#input\_file\_checksum) | The checksum value of `file_url`.
See [packer-builder-arm](https://github.com/mkaczanowski/packer-builder-arm#remote-file). | `string` | `""` | no |
| [file\_checksum\_type](#input\_file\_checksum\_type) | The checksum type of `file_checksum_url`.
See [packer-builder-arm](https://github.com/mkaczanowski/packer-builder-arm#remote-file). | `string` | `"sha256"` | no |
| [file\_checksum\_url](#input\_file\_checksum\_url) | The checksum file URL of `file_url`.
See [packer-builder-arm](https://github.com/mkaczanowski/packer-builder-arm#remote-file). | `string` | `""` | no |
| [file\_target\_extension](#input\_file\_target\_extension) | The file extension of `file_url`.
See [packer-builder-arm](https://github.com/mkaczanowski/packer-builder-arm#remote-file). | `string` | `"zip"` | no |
| [file\_url](#input\_file\_url) | The URL of the OS image file.
See [packer-builder-arm](https://github.com/mkaczanowski/packer-builder-arm#remote-file). | `string` | n/a | yes |
| [git\_commit](#input\_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](#input\_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](#input\_image\_path) | The file path the new OS image to create. | `string` | n/a | yes |
| [kernel\_modules](#input\_kernel\_modules) | List of Linux kernel modules to enable, as seen in `/etc/modules` | `list(string)` | `[]` | no |
| [locales](#input\_locales) | List of locales to generate, as seen in `/etc/locale.gen`. | `list(string)` |[| no |
"en_CA.UTF-8 UTF-8",
"en_US.UTF-8 UTF-8"
]
| [wpa\_supplicant\_country](#input\_wpa\_supplicant\_country) | The [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code in which the device is operating.
Required by the wpa\_supplicant. | `string` | `"CA"` | no |
| [wpa\_supplicant\_enabled](#input\_wpa\_supplicant\_enabled) | Create a [`wpa_supplicant.conf` file](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md) 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](#input\_wpa\_supplicant\_pass) | The WiFi password. | `string` | `""` | no |
| [wpa\_supplicant\_path](#input\_wpa\_supplicant\_path) | The local path to existing `wpa_supplicant.conf` to copy to the image. | `string` | `"/tmp/dummy"` | no |
| [wpa\_supplicant\_ssid](#input\_wpa\_supplicant\_ssid) | The WiFi SSID. | `string` | `""` | no |