Tool to generate Packer configurations from YAML and Jinja2
Project description
packer-config-gen
packer-config-gen (pcg) streamlines your golden image pipeline by separating data (YAML) from build logic (Jinja2). It serves as an orchestration layer that takes clean, inheritable VM specifications and automatically renders:
- Complex Packer manifests (
.pkr.hcl). - OS autoinstall configurations (Ubuntu autoinstall, Preseed, Kickstart).
Define your infrastructure once in YAML, and let pcg handle the boilerplate.
Prerequisites
- Python 3.13
Installation
Available on PyPI
pip install packer-config-gen
Usage
The tool expects the following structure in your working directory:
.
├── .env # Secrets (SSH_PASS, API_TOKEN)
├── configs/
│ ├── hypervisor.yaml # General settings (Proxmox/vSphere/VirtualBox)
│ └── os/
│ └── ubuntu.yaml # OS-specific settings
├── templates/
│ ├── hypervisor.pkr.hcl.j2 # Main Packer template
│ └── subiquity/ # Installer template folder
│ ├── user-data.j2
│ └── meta-data.j2
└── artifacts/ # Output directory (auto-generated)
Examples of repositories that use this utility:
- https://github.com/serhii9132/packer-vbox-builds
- https://github.com/serhii9132/packer-proxmox-builds
- https://github.com/serhii9132/packer-vmware-builds
1. OS configuration example (configs/os/ubuntu.yaml):
packer_builder_name: "ubuntu"
guest_os_type: "Ubuntu_64"
vm_name: "ubuntu-24.04-lts"
iso_config:
url: "https://releases.ubuntu.com/noble"
file: "ubuntu-24.04.3-live-server-amd64.iso"
checksum: "file:https://releases.ubuntu.com/noble/SHA256SUMS"
boot_command:
- "e<wait><down><down><down><end><bs><bs><bs><bs><wait>"
- "ipv6.disable=1 \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" autoinstall ---<wait>"
- "<f10><wait>"
installer: "subiquity"
installer_files:
- meta-data
- user-data
2. Environment variables example:
export USERNAME="user"
export PASSWORD='$6$vPP.....' # Use: mkpasswd -m sha-512
export SSH_PUBLIC_KEY='ssh-ed25519 AAAAbbbbbbbccccccc....'
export SSH_PRIVATE_KEY_FILE="/home/user/.ssh/key"
3. Hypervisor configuration example (configs/hypervisor.yaml)
system_settings:
cpus: 2
memory: 2048
gfx_vram_size: 16
firmware_type: "efi"
export_format: "ova"
communicator: "ssh"
timezone: ""
vboxmanage_commands:
- [ "modifyvm", "{{.Name}}", "--audio", "none" ]
- [ "modifyvm", "{{.Name}}", "--vrde", "off" ]
iso_config:
interface: "sata"
source: ".cache/iso"
disk_config:
size: 150000
interface: "sata"
is_discard: false
is_nonrotational: false
guest_additions:
mode: "upload"
path: "/tmp/VBoxGuestAdditions.iso"
ssh_config:
username: ""
password: ""
private_key_file: ""
pub_key: ""
timeout: "30m"
boot_control:
boot_wait: "5s"
shutdown_command: "sudo shutdown -P now"
Run the pcg command, passing the OS configuration filename:
pcg --os ubuntu
Result: The following files will be created in the artifacts/ubuntu/ folder:
- ubuntu.pkr.hcl
- cidata/user-data
- cidata/meta-data
Now you can start the build:
packer build artifacts/ubuntu/ubuntu.pkr.hcl
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file packer_config_gen-1.3.tar.gz.
File metadata
- Download URL: packer_config_gen-1.3.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d63636071a6202973690a116a03b46f651dd1c49eb8b1ca055812911370104f
|
|
| MD5 |
e7d11f05bb90b845ef99f10d9904a4db
|
|
| BLAKE2b-256 |
379ce1f235069e5789982bc040b6232ac0c208571ec621a38215f1ce772389ef
|
Provenance
The following attestation bundles were made for packer_config_gen-1.3.tar.gz:
Publisher:
ci.yaml on serhii9132/packer-config-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
packer_config_gen-1.3.tar.gz -
Subject digest:
6d63636071a6202973690a116a03b46f651dd1c49eb8b1ca055812911370104f - Sigstore transparency entry: 891264765
- Sigstore integration time:
-
Permalink:
serhii9132/packer-config-gen@9c13e7f624f4f646fe6a61a8bfe6e3f9d3f171a4 -
Branch / Tag:
refs/tags/v1.3 - Owner: https://github.com/serhii9132
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@9c13e7f624f4f646fe6a61a8bfe6e3f9d3f171a4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file packer_config_gen-1.3-py3-none-any.whl.
File metadata
- Download URL: packer_config_gen-1.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8615f261224aecfc024cf7adc3290df21f2a43d1d7ebb2b7b63a92adfbf99e0d
|
|
| MD5 |
3003ceb0ec420aad92700bff42e9bcc5
|
|
| BLAKE2b-256 |
5b414651989c4b1389e717d172737847d6d5d70d3ffebc7fc33543e8e1cff295
|
Provenance
The following attestation bundles were made for packer_config_gen-1.3-py3-none-any.whl:
Publisher:
ci.yaml on serhii9132/packer-config-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
packer_config_gen-1.3-py3-none-any.whl -
Subject digest:
8615f261224aecfc024cf7adc3290df21f2a43d1d7ebb2b7b63a92adfbf99e0d - Sigstore transparency entry: 891264799
- Sigstore integration time:
-
Permalink:
serhii9132/packer-config-gen@9c13e7f624f4f646fe6a61a8bfe6e3f9d3f171a4 -
Branch / Tag:
refs/tags/v1.3 - Owner: https://github.com/serhii9132
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@9c13e7f624f4f646fe6a61a8bfe6e3f9d3f171a4 -
Trigger Event:
push
-
Statement type: