This covers Packer and Terraform configuration for building the VM template and provisioning infrastructure on Proxmox.
Packer
credentials.pkr.hcl
Holds your Proxmox API credentials. Do not commit this to a public repository.
proxmox_api_url = "https://your-proxmox-ip-or-fqdn/api2/json"proxmox_api_token_id = "terraform_user@pam!homelab"proxmox_api_token_secret = "your-proxmox-api-token-secret"To generate a Proxmox API token: tutorial. More Packer examples: here.
packer.pkr.hcl
Plugin configuration for the Proxmox provider:
packer { required_plugins { proxmox-iso = { version = ">= 1.0.0" source = "github.com/hashicorp/proxmox" } }}ubuntu-*/ubuntu-server-jammy-docker.pkr.hcl
Replace YOUR_PROXMOX_NODE_NAME with your Proxmox node name and YOUR_IP_DEPLOYMENT_MACHINE with the IP of the machine running the deploy script.
ubuntu-*/http/user-data
Replace YOUR_SSH_KEY with the SSH key generated by homelab_deploy.sh.
Terraform
terraform.tfvars
Holds credentials for Proxmox. Do not commit this to a public repository.
proxmox_api_url = "https://your-proxmox-ip-or-fqdn/api2/json"proxmox_api_token_id = "terraform_user@pam!homelab"proxmox_api_token_secret = "your-proxmox-api-token-secret"proxmox_host = "proxmox-host-ip"proxmox_user = "proxmox-user"proxmox_password = "proxmox-password"modules/docker_vm/main.tf
Replace all placeholders with your values:
YOUR_PROXMOX_NODE_NAMEIP_MACHINE— VM deployment IPGateWay_IPIP_DEPLOYMENT— same asIP_MACHINEYOUR_SSH_KEY— generated byhomelab_deploy.sh
If you’re not using NFS, comment out this block:
Warning
resource "null_resource" "run_ansible_docker" { depends_on = [local_file.ansible_inventory]
provisioner "local-exec" { command = "LC_ALL=C.UTF-8 LANG=C.UTF-8 ansible-playbook -i ../ansible/inventory/inventory.ini ../ansible/roles/nfs_mount/main.yml" }}Other things configured in this file: locales, root SSH login, SSH key auth, and the Ansible integration trigger.
Next Steps
Proceed to the Deployment guide.