Terraform vs Ansible
- Terraform: specialized in provisioning and deprovisioning of cloud infrastructure.
- Ansible: a more general tool that can be used for automation across various domains.
Terraform in Go, Ansible in Python.
Can you use Ansible to fully replace Terraform?
No. Ansible excels at configuration management. Terraform is more for IaC. Actually you can use both.
Use Both
E.g. use Terraform to provision resources on a public cloud, then run ansible to further setup.
- Terraform (you write HCL): provision VM instances, networking (subnetwork, firewall etc), storage (disk); create ssh keys
- Ansible (you write ansible playbooks in yaml): (now VMs are running), config VM instances (e.g. DNS), install software, manage sysmted services, create folders, download files.
- Now the environment is fully setup.