Number | Base of difference | Terraform | Ansible |
1 | Type | When we say about the type of Terraform, it is an orchestration tool. | When we say about the type of Ansible, it is a configuration management tool. |
2 | Language | When we say about the language in Terraform it follows a declarative language. | When we say about the language in Ansible, this will follows a procedural language. |
3 | Infrastructure | Terraform provides support for immutable infrastructure. | Well on the otehr hand Ansible provides support for mutable infrastructure. |
4 | Packaging and templating | Terraform provides partial support for Packaging and templating | On the other hand Ansible provides complete support for Packaging and templating |
5 | VM Provisioning | Terraform provide comprehensive VM provisioning, networking and storage management. | Ansible provides partial VM provisioning, networking and storage management. |
6 | Write | HCL(HashiCorp Configuration Language) is mainly used to write Terraform scripts. And this is a domain specific language created for describing infrastructure. | Ansible uses YAML (Yet ANother Markup Language) for writing playbooks, whcih are the configurations and automation sequences. |
7 | Workflow | When we say about the workflow, Terraform follows mainly two step process. ANd these two process are Plan and apply. We can create a Terraform script by describing the desired infrastructure, run the Terraform plan to see the changes that will be made, and then execute Terraform to apply those changes. | Ansible operates in a more imperative fashion. You define tasks in playbooks, and Ansible executes them on the target machines. There isn't a separate planning step like in Terraform. |
8 | Lifecycle management | Terraform will support lifecycle management. | Ansible will not support lifecycle management. |
9 | Open Source | It is open source but now a days some change are in progress. | Open source |
10 | Architecture | Client only | Client only |
11 | Cloud | All clouds | All clouds |
12 | Execution Control | Yes here we have execution control. | No here any of computer can be a controller. |
13 | Agent requirement | Terraform not require any extra agent to install. | Ansible will also not require any extra agents to be installed on the server to install. |
14 | Master Server | Terraform is also master less. It communicates with the cloud providers using API. And they do not require any extra infrastructure authentication mechanism.
| Ansible is master less. Some other tools like chefs, puppets require the master server to store the changes and distribute the update but there are disadvantages such as extra secuirty and infrastructure maintenance which incurs cost. |