Terraform and Ansible solve different layers of automation. Terraform provisions resources (VMs, networks, DNS records) and tracks
state. Ansible configures machines that already exist — packages, files, services — usually over SSH without an agent.
They complement each other: Terraform creates a Proxmox VM (see
Terraform on Proxmox), Ansible hardens it (see
Ansible playbook basics).
Different Layers, Not Rivals
Think provision → configure. Terraform talks to cloud APIs; Ansible talks to SSH/WinRM on hosts.
Terraform apply --> VM + network exist --> Ansible playbook --> packages, configs, services running

Terraform and State
Plans are declarative. State files remember what Terraform created so it can update or destroy safely. Store remote state with locking in teams.
terraform init
terraform plan
terraform apply

Ansible and Idempotence
Playbooks describe desired state; rerunning should be safe. Inventory lists hosts; roles organize tasks.
ansible all -m ping

Use Terraform When
Creating VMs, subnets, load balancers, buckets, DNS — anything with a cloud API or provider plugin (including Proxmox).

Use Ansible When
Installing Nginx, deploying app configs, users, cron, hardening SSH — work inside the OS after it exists.

Running Them Together
CI job: terraform apply → wait for SSH → ansible-playbook site.yml. Pass new IPs via inventory plugins or dynamic inventory from Terraform outputs.

Where to Start Learning
Only managing a few hand-built VPS? Start Ansible. Building cloud infra from scratch? Start Terraform. Production teams almost always use both.

Quick Reference
| Terraform | Ansible | |
|---|---|---|
| Primary job | Provision infrastructure | Configure servers/apps |
| Agent | No (API calls) | No (SSH/WinRM) |
| State file | Yes (critical) | No central state by default |
| Destroy resources | Built-in destroy |
Not its focus |
| Together? | Common: Terraform creates, Ansible configures | |
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.