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-initinstalled
After running the builder, it will do the following:
- Clone existing template by given name
- Add a SSH communicator configuration via cloud-init
- Connect via SSH and run the shell provisioner scripts to prepare the VM for Ansible
- Install and start
qemu-guest-agent - Run the Ansible provisioner with the
ansible/common.ymlplaybook - Stop and convert the VM into a template with a new (and empty) cloud-init drive
Variables
| Variable | Description | Type | Default |
|---|---|---|---|
| proxmox_url | Proxmox URL Endpoint | string | |
| proxmox_username | Proxmox username | string | |
| proxmox_password | Proxmox pw | string | |
| proxmox_node | Proxmox node to start VM in | string | pve |
| clone_vm | Name of existing VM template to clone | string | |
| vm_id | ID of final VM template | number | 5000 |
| vm_name | Name of final VM template | string | |
| template_description | Description of final VM template | string | |
| cores | Number of CPU cores | number | 1 |
| sockets | Number of CPU sockets | number | 1 |
| memory | Memory in MB | number | 1024 |
| ssh_username | User to SSH into during provisioning | string | |
| ip_address | Temporary IP address of VM template | string | 10.10.10.250 |
| gateway | Gateway of VM template | string | 10.10.10.1 |
| ssh_public_key_path | Custom SSH public key path | string | |
| ssh_private_key_path | Custom SSH private key path | string |
Proxmox-ISO
This builder configuration is a work-in-progress!!
The proxmox-iso builder creates a VM template from an ISO file.
Variables
| Variable | Description | Type | Default |
|---|---|---|---|
| proxmox_url | Proxmox URL Endpoint | string | |
| proxmox_username | Proxmox username | string | |
| proxmox_password | Proxmox pw | string | |
| proxmox_node | Proxmox node to start VM in | string | pve |
| iso_url | URL for ISO file to upload to Proxmox | string | |
| iso_checksum | Checksum for ISO file | string | |
| vm_id | ID of created VM and final template | number | 9000 |
| cores | Number of CPU cores | number | 1 |
| sockets | Number of CPU sockets | number | 1 |
| memory | Memory in MB | number | 1024 |
| ssh_username | User to SSH into during provisioning | string |
Build Images
-
Create and populate the
auto.pkrvars.hclvariable file. -
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-proxmoxv1.1.2.
Notes
- Currently, only
proxmox_usernameandproxmox_passwordare supported for authentication. - The given
ssh_usernamemust already exist in the VM template when usingproxmox-clone.