packer/README.md
phg eded7180dc Refactor Debian 13 Trixie Packer templates for LUKS support
- Removed obsolete variable files: variables-common.pkr.hcl and variables.pkr.hcl.
- Updated debian-trixie.pkr.hcl to include local values for LUKS configuration.
- Modified boot command to include LUKS arguments based on the enable_luks variable.
- Enhanced initial-setup.sh to support LUKS detection and resizing.
- Replaced preseed.cfg with preseed.cfg.pkrtpl for dynamic LUKS configuration.
- Added enable_luks variable to control LUKS encryption during image build.
- Introduced luks.pkrvars.hcl for LUKS-specific variable settings.
- Updated mise.toml to support new variable file argument for Packer builds.
2026-05-11 19:13:11 +02:00

122 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Packer based PVE image templates
## Table of Contents
- [Packer based PVE image templates](#packer-based-pve-image-templates)
- [Table of Contents](#table-of-contents)
- [Templates](#templates)
- [Repository structure](#repository-structure)
- [Initial Setup](#initial-setup)
- [Create Token](#create-token)
- [Initialize Packer](#initialize-packer)
- [Build](#build)
- [Build LUKS encrypted Templates](#build-luks-encrypted-templates)
- [Setup new templates](#setup-new-templates)
## Templates
| Template ID | OS | Version | Path | LUKS encrypted? | Mac Address | IP Address |
| :---------- | :--------------------------------------------------------------------------------------------- | :-------- | :---------------------- | :-------------- | :---------------- | :---------------------- |
| 65000 | <img src="https://www.debian.org/logos/openlogo-nd.svg" alt="Debian logo" height="16"/> Debian | 13-trixie | `debian/13-trixie` | optional | BC:24:11:00:13:37 | 192.168.9.29 (via DHCP) |
## Repository structure
```shell
la 4 -I .git
Name
 ./
├──  _scripts/ Support scripts for building templates.
│ └──  unlock-luks-after-install.py* Unlocks the LUKS encrypted Disk on the 1st Boot after installation.
├──  debian/ Debian template definitions and assets (Packer templates, cloud-init/KS files, provisioning files).
│ └──  13-trixie/ Template definition and assets for the Trixie template.
│ ├──  files/ Files used for the file provisioner.
│ │ ├── 󱁻 99-pve.cfg Configures the data sources for cloud-init.
│ │ └──  debian.sources Debian package sources.
│ ├──  http/ Files that Packer provides during build via http.
│ │ └── 󱁻 preseed.cfg.pkrtpl Debian preseed template.
│ ├──  variants/ Packer var-files for optional image variants.
│ │ └──  luks.pkrvars.hcl Enables LUKS encryption.
│ ├──  credentials.auto.pkrvars.hcl -> ../../credentials.auto.pkrvars.hcl Local secrets for Packer (API token, endpoints) used at build time.
│ ├──  debian-trixie.pkr.hcl The build template.
│ ├──  variables-common.pkr.hcl -> ../../variables-common.pkr.hcl Shared Packer variables used by templates.
│ └──  variables.pkr.hcl Packer variables only used for this template.
├──  OS/ Diretory to group templates for a specific OS.
│ └──  version_number[-version_codename][-luks]/ Template definition and assets.
├──  downloaded_iso_path/ Packer ISO cache directory (downloaded ISOs and lock files).
│ ├──  OS.iso
│ ├──  OS.iso.lock
│ ├──  [...].iso
│ └──  [...].iso.lock
├── 󰊢 .gitignore
├──  credentials.auto.pkrvars.hcl Local secrets for Packer (API token, endpoints) used at build time.
├──  mise.toml Task runner definitions for init/build/setup.
├── 󰂺 README.md
├──  template-credentials.pkrvars.hcl Template to create `credentials.auto.pkrvars.hcl`.
└──  variables-common.pkr.hcl Shared Packer variables used by templates.
```
## Initial Setup
### Create Token
1. Copy `template-credentials.pkr.hcl` to `credentials.auto.pkrvars.hcl`
2. Open your Proxmox VE web interface & Login.
3. Navigate to: `Datacenter` -> `Permissions` -> `API Tokens`
4. **Click:** Add
5. **Configure in the dialog:**
1. **User:** `root@pam` (or the user you like, but It needs administrative permissions)
2. **Token ID:** `packer`
3. **Privilege Separation:** false
6. **Click:** Add
7. Copy the displayed Token ID and Token Secret to `credentials.auto.pkrvars.hcl`
### Initialize Packer
Run `packer init` to initialize Packer according to a HCL template
configuration. It's downloads and installs the required Plugins according to
the required_plugins block in Packer templates.
```shell
mise run init <path-to-template-directory>
```
## Build
To build a template run:
```shell
mise run build <path-to-template-directory>
```
For Debian 13 Trixie without LUKS:
```shell
mise run build debian/13-trixie
```
## Build LUKS encrypted Templates
Debian LUKS builds use the same template directory and enable encryption through
`debian/13-trixie/variants/luks.pkrvars.hcl`.
To build a LUKS encrypted Debian 13 Trixie template run:
```shell
mise run build-luks debian/13-trixie
```
The equivalent direct Packer command is:
```shell
packer build -var-file=debian/13-trixie/variants/luks.pkrvars.hcl debian/13-trixie
```
## Setup new templates
Run:
```shell
mise run setup <distribution name> <version>
```
E.g. `mise run setup debian 13-trixie`.