:package: Packer templates for building Proxmox KVM images from ISO
The build script which will run the packer template is configured to run on the Proxmox server. Thus the following pre-requisites should be installed on the Proxmox server:
vmbr1
, for example isc-dhcp-server
(see section DHCP in the Proxmox Ansible role).printf "Proxmox $(pveversion)\n"
apt -y install unzip
packer_ver=1.5.5
wget https://releases.hashicorp.com/packer/${packer_ver}/packer_${packer_ver}_linux_amd64.zip
sudo unzip packer_${packer_ver}_linux_amd64.zip -d /usr/local/bin
packer --version
apt -y install python3-pip
pip3 install ansible==2.9.7
pip3 install py-bcrypt
pip3 install j2cli[yaml]
wget https://github.com/chriswayg/packer-proxmox-templates/archive/v1.7.zip && unzip v1.7.zip && cd packer-proxmox-templates-*
On the Proxmox Server with Packer installed:
cd OSname-xy-amd64-proxmox
# for example
cd debian-10-amd64-proxmox
cd ubuntu-18.04-amd64-proxmox
cd openbsd-6-amd64-proxmox
build.conf
, including the default user and especially the Proxmox URL and the ISO download links for the latest distro versionplaybook/server-template-vars.yml
, especially the SSH Key & regional repositories../build.sh proxmox
build.conf
, or login as root via console (if not disabled)../build.sh (proxmox|debug [new_VM_ID])
proxmox - Build and create a Proxmox VM template
debug - Debug Mode: Build and create a Proxmox VM template
VM_ID - VM ID for new VM template (or use default from build.conf)
Enter Passwords when prompted or provide them via ENV variables:
(use a space in front of ' export' to keep passwords out of bash_history)
export proxmox_password=MyLoginPassword
export ssh_password=MyPasswordInVM
The Packer templates have been tested with the following versions of Packer and Ansible. If you use different versions, some details may need to be updated.
printf "$(lsb_release -d) $(cat /etc/debian_version)\n" && \
printf "Proxmox $(pveversion)\n" &&
packer version && \
ansible --version | sed -n '1p' && \
ansible --version | sed -n '6p' && \
j2 --version
Description: Debian GNU/Linux 10 (buster) 10.3
Proxmox pve-manager/6.1-8/806edfe1 (running kernel: 5.3.18-3-pve)
Packer v1.5.5
ansible 2.9.7
python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
j2cli 0.3.10, Jinja2 2.11.2
NOTE: For security reasons it would be preferable to build the Proxmox template images on a local Proxmox staging server (for example in a VM) and then to transfer the Proxmox templates using migration onto the live server(s).
It should also be possible to use Packer remotely and to control VM creation remotely via Ansible. The Packer template and the scripts would have to be modified accordingly. If you have it working remotely, please make a pull request.