<p>I think you have to consider the history of the two tools to answer this question properly:</p>

<ul>
<li><p><strong>Ansible</strong> was created to manage the installation and maintenance of virtual machines, thus it originally only had the capability to install software into an operating system, perform systems administration tasks <em>within</em> that machine.  Subsequently, it has been extended to be able to create cloud resources in AWS, Azure, GCP and others.</p></li>
<li><p><strong>Terraform</strong> was created to manage cloud resources, it's effectively a facade layer over the various APIs in AWS, Azure, GCP, etc.  It has subsequently been extended to be able to cover many of the functions that Ansible also covers such as installing software.</p></li>
</ul>

<p>My personal workflow is to use both applications for what they are <strong>really good at</strong>, thus I create infrastructure (Virtual Machines, Clusters, Storage, Networks, etc) in Terraform and then use Ansible to install and configure software as required.</p>

<p>I can, and have in some situations, just used Terraform or Ansible, it's just a little harder as you have to learn how to use one tool in a different way.</p>

<p><a href="https://devops.stackexchange.com/users/354/bruce-becker">Bruce Becker</a> pointed out in a comment that one of the main differences is the fact that Terraform is "eventually consistent", in that it does a good job of understanding the current state and then making changes that converge on a "desired state". This workflow is better for the majority of tasks than Ansible. In Ansible you can do a test run with <code>--check</code>, but this doesn't always take into account cascading changes.</p>

CC BY-SA 4.0
2019-11-13T08:42:35.303Z
One of the main differences for me is the fact that Terraform is eventually consistent. It's much better than Ansible at creating a plan and then applying it. Sure, you can do a test run with -C, but this doesn't always take into account cascading changes. Would you like to update the answer with these additions Richard?
Bruce Becker
CC BY-SA 4.0
2019-11-13T10:13:22.410Z
Good Shout @BruceBecker - it's a good call, although in my experience you quite quickly end up in a similar situation if you try and use Terraform to perform tasks within the Virtual Machine.  I suspect the reason Ansible operates in the way it operates is more to do with the lack of idempotency within various software packages that make up Linux as a whole.  Hence the reasons why organisations end up going down the route of using Packer or Containers and Immutable Infrastructure.
Richard Slater
CC BY-SA 4.0
2023-12-16T19:27:13.493Z
[A comparison between Terraform and Ansible on their impact upon the lifecycle and security management ...](https://www.diva-portal.org/smash/get/diva2:1678017/FULLTEXT02)
U880D
CC BY-SA 4.0
2019-11-12T10:29:27.670Z
2019-11-13T10:11:08.880Z
2019-11-13T10:11:08.880Z
Richard Slater
<p>What is Ansible mainly used for?</p>

<p>Where do I use Terraform?</p>

<p>This question focusses on where the tools have relative strengths or weaknesses. </p>

<p>For example: </p>

<ul>
<li>Ansible for VM build and Software installation. </li>
<li>Terraform for Configuration (Apply and Enforce) and Compliance Enforcements. </li>
<li>Terraform is used to Setup Cloud Environments mainly  etc.</li>
</ul>

<p>Hope this helps the question be more precisely answered</p>

CC BY-SA 4.0
2019-11-12T10:25:51.110Z
Hi! It would really help if you could narrow down the question a bit - it is very wide open to interpretation. If you could give us some idea of your situation or use cases, this would help guide the answers. Else this question risks being closed as "too broad". Thanks!
Bruce Becker
CC BY-SA 4.0
2019-11-13T13:06:28.870Z
Hi there I see that both tools are used. The questions goes into the directions where is either tool having strengths or weaknesses. Even more I like to get an idea of the community where either of these tools is used in the field. For example:  Ansible for VM build and Software installation. Terraform for Configuration ( Apply and Enforce) and Compliance Enforcements. Hope that helps that answers can be more precisely.
user287144
CC BY-SA 4.0
2023-12-16T19:26:41.443Z
[A comparison between Terraform and Ansible on their impact upon the lifecycle and security management ...](https://www.diva-portal.org/smash/get/diva2:1678017/FULLTEXT02)
U880D
<ansible><terraform>
Where do I use Ansible and where is Terraform used? ( Strengths & Weaknesses)
user287144
# Where do I use Ansible and where is Terraform used? ( Strengths & Weaknesses)

(Asked by: username_0 on 2019-11-12)

What is Ansible mainly used for?

Where do I use Terraform?

This question focusses on where the tools have relative strengths or weaknesses.

For example:

* Ansible for VM build and Software installation.
* Terraform for Configuration (Apply and Enforce) and Compliance Enforcements.
* Terraform is used to Setup Cloud Environments mainly etc.

Hope this helps the question be more precisely answered

**Tags:** ansible, terraform

> **Comments:**
> **username_1**: Hi! It would really help if you could narrow down the question a bit - it is very wide open to interpretation. If you could give us some idea of your situation or use cases, this would help guide the answers. Else this question risks being closed as "too broad". Thanks!  
> **username_0**: Hi there I see that both tools are used. The questions goes into the directions where is either tool having strengths or weaknesses. Even more I like to get an idea of the community where either of these tools is used in the field. For example:  Ansible for VM build and Software installation. Terraform for Configuration ( Apply and Enforce) and Compliance Enforcements. Hope that helps that answers can be more precisely.  
> **username_2**: [A comparison between Terraform and Ansible on their impact upon the lifecycle and security management ...](https://www.diva-portal.org/smash/get/diva2:1678017/FULLTEXT02)  

---

## 1 answers

### Answer by username_3 on 2019-11-12. Score: 6

I think you have to consider the history of the two tools to answer this question properly:

* **Ansible** was created to manage the installation and maintenance of virtual machines, thus it originally only had the capability to install software into an operating system, perform systems administration tasks *within* that machine. Subsequently, it has been extended to be able to create cloud resources in AWS, Azure, GCP and others.
* **Terraform** was created to manage cloud resources, it's effectively a facade layer over the various APIs in AWS, Azure, GCP, etc. It has subsequently been extended to be able to cover many of the functions that Ansible also covers such as installing software.

My personal workflow is to use both applications for what they are **really good at**, thus I create infrastructure (Virtual Machines, Clusters, Storage, Networks, etc) in Terraform and then use Ansible to install and configure software as required.

I can, and have in some situations, just used Terraform or Ansible, it's just a little harder as you have to learn how to use one tool in a different way.

[username_1](https://devops.stackexchange.com/users/354/bruce-becker) pointed out in a comment that one of the main differences is the fact that Terraform is "eventually consistent", in that it does a good job of understanding the current state and then making changes that converge on a "desired state". This workflow is better for the majority of tasks than Ansible. In Ansible you can do a test run with `--check`, but this doesn't always take into account cascading changes.

> **Comments:**
> **username_1**: One of the main differences for me is the fact that Terraform is eventually consistent. It's much better than Ansible at creating a plan and then applying it. Sure, you can do a test run with -C, but this doesn't always take into account cascading changes. Would you like to update the answer with these additions Richard?  
> **username_3**: Good Shout @BruceBecker - it's a good call, although in my experience you quite quickly end up in a similar situation if you try and use Terraform to perform tasks within the Virtual Machine.  I suspect the reason Ansible operates in the way it operates is more to do with the lack of idempotency within various software packages that make up Linux as a whole.  Hence the reasons why organisations end up going down the route of using Packer or Containers and Immutable Infrastructure.  
> **username_2**: [A comparison between Terraform and Ansible on their impact upon the lifecycle and security management ...](https://www.diva-portal.org/smash/get/diva2:1678017/FULLTEXT02)  

---

