Whats the main difference between ansible and terraform? at least three differen . . .

Murali Krishna Reddy Dasari:
whats the main difference between ansible and terraform? at least three differences

Alistair Mackay:
Here’s 3 for a start

  1. Purpose: Ansible is primarily used for configuration management and automation, while Terraform is used for infrastructure as code. Terraform is better suited to creating infrastructure like deploying networks and servers in the cloud, where Ansible, once you have a bunch of running servers defines how they are configured, e.g. what users accounts, software etc. should be on them.
  2. Execution: Ansible uses a push model, where it pushes changes to the target systems, while Terraform uses a pull model, where it queries the target systems for their current state and makes changes accordingly.
  3. Language: Ansible uses YAML for its configuration files, while Terraform uses its own HashiCorp Configuration Language (HCL).

MK:
one more main difference i’d include, by default Ansible(Imperative) and Terraform(Declarative) ………… Interviewers really feel unsatisfied without this one :grinning:

Murali Krishna Reddy Dasari:
Can u elaborate more on this imperative and declarative :slightly_smiling_face:

MK:
Ansible (Imperative nature) means you tell via your code…what to do ( to the system you’re managing)

Terraform (Declarative nature) means you tell via your code… simply where to reach :+1:

Murali Krishna Reddy Dasari:
Can u give me example

Murali Krishna Reddy Dasari:
One diff I could think is destroying is easy in terraform where as ansible we need to write code to destroy

MK:
you’re basically saying the same thing. what i meant

Murali Krishna Reddy Dasari:
Ok

Bishop Mbong:
One could argue that Ansible is declarative… for example, to create a user in Linux, we do not need to type useradd, etc…we just specify the module and module parameters and ansible does the rest