Use this when creating reusable definitions — VM templates, Terraform modules, cloud-init or Ansible roles — that produce many consistent VMs.
Templates · Automation
Automation templates are reusable definitions — a VM template, a Terraform module, a cloud-init or Ansible role — with parameters for name, size and network, so many VMs can be produced from one tested pattern.
1. Templates are the automation base.
2. Build with Packer.
3. Version and test.
4. Include cloud-init/agents.
5. Rebuild regularly.
Packer → template → clones
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
- Template version recorded in the VM's notes/tags.
- Template patched within the last month.
- Test deployment from the template succeeds.
Step 2 Common mistakes Narrow the fault
- Templates built by hand and impossible to reproduce.
- No version or changelog.
- Secrets embedded in templates.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Parameters, not copies.
- Version templates and modules.
- Test a template before others depend on it.
qm list— templates (Proxmox)packer build .— image buildGet-VM -Name tpl-*— Hyper-V templates
ReferenceWhy it matters1 section · depth on demand
Packer example
packer init .
packer validate .
packer build -var 'version=2026.11' debian12.pkr.hcl
Documented example, not captured output.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Templates are golden images to clone from. Keep them small and generic:
- Latest patches; guest tools/agents installed; cloud-init or sysprep prepared.
- No unique identity: no machine IDs (
/etc/machine-idemptied), SSH host keys removed, no domain join. - Hardened baseline (CIS level 1), logging and monitoring agents pre-installed but unconfigured.
- Documented version and build date; rebuilt monthly by automation.
truncate -s 0 /etc/machine-id; rm -f /etc/ssh/ssh_host_*; cloud-init clean --logs
qm template 9000
Template types
| Type | Example |
|---|---|
| VM template | vSphere template, Proxmox template VM |
| Image | Packer-built qcow2/VMDK/VHDX, cloud images |
| Code module | Terraform module, Ansible role |
| Guest config | cloud-init user-data, Sysprep answer file |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation → Templates. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/html/index.html · confidence 94%