You are on page 1of 2

Terraform Ansible

Terraform is a provisioning tool. Ansible is a configuration management tool.


It follows a declarative Infrastructure as a Code
approach. It follows a procedural approach.
It is the best fit for orchestrating cloud services and It is mainly used for configuring servers with the right
setup cloud software and
infrastructure from scratch. updates already configured resources.
Terraform does not support bare metal
provisioning by default. Ansible supports the provisioning of bare metal servers.
It does not provide better support in terms of
packaging and templating. It provides full support for packaging and templating.
It highly depends on lifecycle or state management. It does not have lifecycle management at all.
DIFFERENCE BETWEEN TERRAFORM AND ANSIBLE:

Configuration Management vs. Orchestration:


Ansible solve the issues locally rather than replacing the system entirely.

Terraform ensure that an environment is in its desired state continuously.

Logically, we can identify orchestration as Day 0 activity and configuration management as Day 1
activity. Terraform works best for Day 0 activities and Ansible for Day 1 and onwards activities.

Procedural vs Declarative:
Terraform is used to write infrastructure as code (IaC). It uses HCL (Hashicorp Configuration
Language) which is declarative in nature.
It doesn’t matter in which sequence the code is written. The code could also be dispersed in multiple
files.

Ansible uses YAML syntax to define the procedure to perform on the target infrastructure.
Ansible YAML scripts are procedural in nature – meaning when you write the script, it will be executed
from top to bottom.

State Management:
Terraform manages the entire lifecycle of the resources under its management.
States are used to track changes to the configuration and provision the same. 

Ansible does not support any lifecycle management.


Ansible mainly deals with configuration management and considering it defaults to immutable
infrastructure, any changes introduced in the configuration are executed automatically on the target
resource.

You might also like