Table of Contents
What is ansible and what is terraform
Ansible is a simple IT automation program that helps to deploy, configure and manage nodes. Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently from code. It is used to create and manage the infrastructure you depend on. Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently from code. It is used to create and manage the infrastructure you depend on.
What is ansible ?
Ansible is a simple IT automation program that helps to deploy, configure and manage nodes. It uses ssh to connect to remote host, transferring files using scp or sftp. Ansible can also work over ssh without password prompt by using key based authentication, but doing so is not recommended in production environment. Ansible also supports other protocols such as http or winrm (on windows). Most of all, Ansible can run on any operating systems that has python installed.
Here is an Example to demonstrate how simple Ansible could be:

How are they different
Ansible is a configuration management tool, which helps to provision and configure machines (Linux, Windows, etc), it manages services. Terraform is a tool that helps you to manage state of your infrastructure as code. It allows you to create and manage the infrastructure defined in code, without having to run scripts on all your machines every time.
Terraform and ansible are not competing each other, they are complementary, so they are used together.
Ansible is a configuration management tool, which helps to provision and configure machines (Linux, Windows, etc), it manages services. This fits well with Terraform State of Code: It allows you to create and manage the infrastructure defined in code without having to run scripts on all your machines every time.
Terraform is a tool that helps you to manage state of your infrastructure as code. It allows you to create and manage the infrastructure defined in code, without having to run scripts on all your machines every time. You can think of Terraform as a mix between Ansible and Puppet.

What are the pros and cons of each
Both Ansible and Terraform are tools used by developers to automate the configuration of a system. They make it easy to create programs and applications. Both Ansible and Terraform can perform many tasks that you would need to do manually, where it saves time and money. When you have a big infrastructure, like AWS or GCP for example, you need a tool that can help you manage the code easily, terraform is good for this. But if you only have a few servers, like 3-4 servers, then Ansible will do the job. Also, Ansible provides many operations modules that Terraform does not. For example, Ansible can install packages and configure services such as FTP and NTP. However, when you have a big infrastructure with multiple regions, then Terraform is the best choice.
What do you think?
Let me know in the comments!
Source: Quora.com (https://www.quora.com/What-are-the-pros-and-cons-of-each)
Another good source: https://github.com/gonzomod/ansible_vs_terraform (link to comparison table inside the README)
If you find this article valuable, please hit the 👏 button and feel free to follow me for future posts. Thank you!
If you have any questions or suggestions, please feel free to leave a comment below. I’ll reply ASAP.
Tags: ansible , terraform , aws , compare , ansible vs terraform , aws terraform comparison , sweetlabs tutorial , cloudformation aws playbook comparison (link to my blog post)

When should you use one over the other
Both are good tools to use, but depending on the environment you need, you might want to use one over the other. Terraform is better for managing state of your infrastructure, but Ansible is better for managing things that are not in state, like deploying your application through Ansible and then scaling it up with Terraform. It all depends on what you need. By now, both are pretty matured and you can use whichever you prefer.
» Ansible:
Ansible is an IT automation engine that runs playbooks to configure servers over SSH. Playbooks in Ansible are a YAML file which tell it what to do on the remote machine. Playbooks are the configuration, and modules are what tell it what to do. It has modules for managing various things like databases, ssh, web servers and more. You can not only manage servers, but also instances on a server with Ansible. It uses SSH for remote connections (using the -m command line option), but it delegates everything to a separate machine that you run as ansible-playbook.
…
Terraform:

Which one is better
Terraform is better for managing infrastructure, especially when you have a lot of servers and servers that don’t directly communicate. However, Ansible is great for automating things that are not in state, for example deploying your application with Ansible and then scaling it up with Terraform. It all depends on what you are doing. Ansible is great for managing applications, while Terraform is great for managing infrastructure.
1.
Terraform uses HCL, which stands for Hashicorp Configuration Language.
Ansible uses shell scripting and Python.
Terraform is flexible, but Ansible is more flexible.
Terraform uses HCL, which stands for Hashicorp Configuration Language. HCL allows you to define variables and groups of related resources according to expected state. For example, you can specify a group of servers that are dependent on the availability of a particular cloud provider’s VPC, or on a particular subnet in that VPC.
