This project builds, configures and maintain cloud-init enabled Linux VMs and transform them into templates on Proxmox hypervisor.
To automate this chain, cloud-init images are used in combination with proxmox CLI and packer.
-
Service executes the nightly job, which first fetches the latest cloud-init images, then it creates and configures Proxmox VMs.
-
packer
creates templates from newly prepared VMs and configures the templates with cloud-init defaults (SSH user and public key).
You can easily customize this and add more cloud-init defaults. List of all possible defaults: https://pve.proxmox.com/wiki/Cloud-Init_Support
If the systemd service fails for any reason, it's configured to trigger the notify-email@%i.service
. It also sends a notification with proxmox-mail-forward
on successful build.
- Debian 12 (bookworm)
- AlmaLinux 9 (selinux set to permissive)
- Ubuntu 22.04.3 (Jammy)
Installation is intended to be done on the Proxmox host itself, otherwise it won't work.
apt-get update && apt-get install libguestfs-tools wget vim git unzip
Because I'm using token ID/secret as proxmox authentication method, packer must be install manually to attain newer version than proxmox currently supports as default package. New versions support this auth method and also fixes a lot of bugs you may encounter.
https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli
TLDR Download the newest version (currently 201.9.4) wget https://developer.hashicorp.com/packer/downloads#:~:text=Version%3A%201.9.4-,Download,-AMD64
Unzip && move the precompile file unzip packer* mv packer /usr/bin/
8999, 9000, 8000, 7999, 7000, 6999
Clone the repository to /opt
.
git clone https://github.com/Ard3ny/proxmox-build-template.git /opt/build-template
cd /opt/build-template
If you don't know how, I've explained it in a full tutorial in my blog post.
TLDR over CLI
pveum user add kubernetes@pve
pveum acl modify / -user kubernetes@pve -role Administrator
pveum acl modify / -user kubernetes@pve -role PVEAdmin
pveum user token add kubernetes@pve test_id -privsep 0
Copy the environment variable files and edit them with your own parameters.
cp env .env && cp credentials.pkr.hcl.example credentials.pkr.hcl
vim .env
vim credentials.pkr.hcl
Edit bin/bootstrap* files and add your own packages to be installed.
vim bin/bootstrap_deb.sh
vim bin/bootstrap_ubuntu.sh
vim bin/bootstrap_rhel.sh
By default, the build-template service runs each night at 00:15.
make install
systemctl daemon-reload
systemctl enable --now build-template.timer
/usr/bin/make -C /opt/build-template
I've forked this project originally created by https://github.com/mfin/proxmox-build-template I've fix few bugs, added more cloud-init templates, changed install and auth methods and extended documentation, so big shoutout goes to him.
https://developer.hashicorp.com/packer/integrations/hashicorp/proxmox/latest/components/builder/clone https://www.libguestfs.org/virt-customize.1.html