Terraform + Ansible for a Home Lab
Infrastructure
Provision with Terraform, configure with Ansible - the split that keeps a Proxmox home lab reproducible instead of a pile of hand-clicked VMs.
A home lab rots the moment it becomes un-reproducible. The fix is the same as at work: Terraform provisions the infra, Ansible configures it. Two tools, one clean seam. Built out across Terraform and Ansible in Web_development, running on Proxmox from Software_Tools.
- Terraform: https://bthek1.github.io/IaaS_docs/terraform
- Ansible: https://bthek1.github.io/IaaS_docs/ansible
- Proxmox host: https://bthek1.github.io/Software_Tools/0_proxmox
Two tools, one seam
| Terraform | Ansible | |
|---|---|---|
| Job | Provision (create VMs, networks, storage) | Configure (packages, services, files) |
| Model | Declarative desired-state | Declarative-ish, procedural playbooks |
| State | Tracks a state file | Stateless; idempotent tasks |
| Idempotent | Yes (plan/apply) | Yes (per task) |
| Best at | “What exists” | “How it’s set up” |
The seam: Terraform stops once a VM boots with an IP; Ansible takes over from the IP. Don’t make Terraform install packages, and don’t make Ansible create VMs.
The workflow
The lab it builds
Why bother: hands-on minutes to rebuild
The payoff is disaster recovery. Rebuilding by hand is an afternoon; rebuilding from code is a coffee.
Takeaway
Keep the seam clean and the whole lab lives in git: terraform apply then ansible-playbook rebuilds everything from bare Proxmox. Details in Terraform and Ansible.