Packer

Packer is used to create golden images in Proxmox with the community Proxmox builder plugin.

Two different builders are supported: proxmox-iso and proxmox-clone to target both ISO and cloud-init images for virtual machine template creation in Proxmox.

Proxmox-clone

The proxmox-clone builder creates a new VM template from an existing one. If you do not have an existing VM template or want to create a new template, you can upload a new cloud image and convert it into a new VM template.

Note that this existing template must have:

  • An attached cloud-init drive for the builder to add the SSH communicator configuration
  • cloud-init installed

After running the builder, it will do the following:

  1. Clone existing template by given name
  2. Add a SSH communicator configuration via cloud-init
  3. Connect via SSH and run the shell provisioner scripts to prepare the VM for Ansible
  4. Install and start qemu-guest-agent
  5. Run the Ansible provisioner with the ansible/common.yml playbook
  6. Stop and convert the VM into a template with a new (and empty) cloud-init drive

Variables

VariableDescriptionTypeDefault
proxmox_urlProxmox URL Endpointstring
proxmox_usernameProxmox usernamestring
proxmox_passwordProxmox pwstring
proxmox_nodeProxmox node to start VM instringpve
clone_vmName of existing VM template to clonestring
vm_idID of final VM templatenumber5000
vm_nameName of final VM templatestring
template_descriptionDescription of final VM templatestring
coresNumber of CPU coresnumber1
socketsNumber of CPU socketsnumber1
memoryMemory in MBnumber1024
ssh_usernameUser to SSH into during provisioningstring
ip_addressTemporary IP address of VM templatestring10.10.10.250
gatewayGateway of VM templatestring10.10.10.1
ssh_public_key_pathCustom SSH public key pathstring
ssh_private_key_pathCustom SSH private key pathstring

Proxmox-ISO

This builder configuration is a work-in-progress!!

The proxmox-iso builder creates a VM template from an ISO file.

Variables

VariableDescriptionTypeDefault
proxmox_urlProxmox URL Endpointstring
proxmox_usernameProxmox usernamestring
proxmox_passwordProxmox pwstring
proxmox_nodeProxmox node to start VM instringpve
iso_urlURL for ISO file to upload to Proxmoxstring
iso_checksumChecksum for ISO filestring
vm_idID of created VM and final templatenumber9000
coresNumber of CPU coresnumber1
socketsNumber of CPU socketsnumber1
memoryMemory in MBnumber1024
ssh_usernameUser to SSH into during provisioningstring

Build Images

  1. Create and populate the auto.pkrvars.hcl variable file.

  2. Run the build:

$ packer validate -var-file="auto.pkrvars.hcl" .
$ packer build -var-file="auto.pkrvars.hcl" .

If a template of the same vm_id already exists, you may force its re-creation with the --force flag:

$ packer build -var-file="auto.pkrvars.hcl" --force .

Note: This is only available from packer-plugin-proxmox v1.1.2.

Notes

  • Currently, only proxmox_username and proxmox_password are supported for authentication.
  • The given ssh_username must already exist in the VM template when using proxmox-clone.