BACKGROUND
I'm trying to automate 1) the creation of a template VM and 2) the creation of multiple nodes spawned from the template VM in a Proxmox VE.
I use the Packer Proxmox builder [1] to create the template VM, passing in cloud-init user-data [2] which works for the most part. I can see evidence in VMs spawned from my template that this user-data is applied.
I use Telmate's Proxmox provider plugin [3] for Terraform to create VMs based on the Packer template. A cloud-init user-data file is specified [4] to customize the template-derived VMs.
PROBLEM
I do not see evidence of user-data in the template-derived VMs overriding the values in the template VM. The specific issue is that all template-derived VMs are being created with the same hostname specified in the template VM rather than the VM's name which I would expect.
SUPPLEMENTAL DETAIL
As a test, I've manually applied user-data overrides directly to my template-derived VMs (after provisioning) via
QUESTIONS
[2] https://github.com/mancobian/homelab/blob/master/scripts/create-template-vm/packer/http/user-data
[3] https://github.com/Telmate/terraform-provider-proxmox
[4] https://github.com/mancobian/homelab/blob/master/scripts/create-k8s-cluster/terraform/main.tf#L67
I'm trying to automate 1) the creation of a template VM and 2) the creation of multiple nodes spawned from the template VM in a Proxmox VE.
I use the Packer Proxmox builder [1] to create the template VM, passing in cloud-init user-data [2] which works for the most part. I can see evidence in VMs spawned from my template that this user-data is applied.
I use Telmate's Proxmox provider plugin [3] for Terraform to create VMs based on the Packer template. A cloud-init user-data file is specified [4] to customize the template-derived VMs.
PROBLEM
I do not see evidence of user-data in the template-derived VMs overriding the values in the template VM. The specific issue is that all template-derived VMs are being created with the same hostname specified in the template VM rather than the VM's name which I would expect.
SUPPLEMENTAL DETAIL
As a test, I've manually applied user-data overrides directly to my template-derived VMs (after provisioning) via
qm set <vmid> --cicustom "user=local:snippets/<user-data-file>. However, when I issue qm cloudinit dump <vmid> user, I see the user-data values from the template VM, rather than the override values I would expect as a result of the qm set call.QUESTIONS
- Am I incorrect to assume cloud-init user-data key/values provided to a template-derived VM should override the same values that exist in a template VM?
- If I'm not off-base with my assumption, is this a known issue of some sort?
- In any case, is there a practical workaround to simply update the template-derived VM hostnames from the VM's given name as a post-provisioning step of some sort?
[2] https://github.com/mancobian/homelab/blob/master/scripts/create-template-vm/packer/http/user-data
[3] https://github.com/Telmate/terraform-provider-proxmox
[4] https://github.com/mancobian/homelab/blob/master/scripts/create-k8s-cluster/terraform/main.tf#L67