Ansible or Terraform: where do you draw the line?
BeginnerProductionArchitecture Decisions and Tool Comparisons
Answer
Terraform creates and destroys infrastructure; Ansible configures what runs on it.
| Terraform | Ansible | |
|---|---|---|
| Model | Declarative with a state file | Procedural tasks, mostly idempotent modules |
| Best at | VPCs, instances, IAM, managed services, DNS | OS config, packages, app deploys, orchestration |
| Knows what exists | Yes, via state and plan | No, checks on each run |
| Deletes removed resources | Yes | Only if you write a task for it |
In production we use Terraform for the cloud layer and Ansible for what is inside the instances and for ordered operations (rolling restarts, patching). Using Ansible cloud modules for long-lived infrastructure works but you lose plan and drift visibility.
More on Architecture Decisions and Tool Comparisons
How does Ansible compare with Puppet, Chef and Salt?IntermediateWhy use Ansible instead of shell scripts?BeginnerWhere does Ansible fit once you run Kubernetes?Intermediatecloud-init or Ansible for first boot configuration?IntermediateWhen would you use AWS Systems Manager instead of, or together with, Ansible?IntermediateShould Ansible do application deployments or should a CD tool?Advanced