kentoh - Fotolia


Ansible vs. Terraform vs. Vagrant: What's the difference?

Ansible, Terraform and Vagrant are common infrastructure automation platforms with specific use cases, benefits and drawbacks. But choosing a platform doesn't need to be confusing.

Most network and IT professionals have heard of Ansible, Terraform and Vagrant and likely wonder how they relate to one another. While the three infrastructure automation platforms seem similar, they fulfill different functions.

Below, we compare Ansible, Terraform and Vagrant, diving into their pros and cons and potential use cases.


Ansible is a Python-based IT system configuration automation tool that is roughly comparable to Chef and Puppet in the server world and Nornir in the networking world. It has gained wide acceptance as a network automation system, due in part to its agentless architecture -- no agent needs to be loaded on the system to be automated. Other network automation systems, like NAPALM, are easily integrated with Ansible, broadening vendor support and increasing its appeal.

Ansible's actions are configured using YAML-formatted files, called playbooks, which network engineers are often more comfortable using than programmatic automation frameworks, like Nornir. There is a large Ansible community, and many resources are available to learn how to use Ansible. Red Hat provides a commercially supported version called Ansible Tower.


Below are some of the benefits of Ansible:

  • It uses YAML-formatted playbook files, which network engineers find useful.
  • It has agentless operation.
  • It is multivendor-capable.
  • It has a large community with open source and vendor support.


Ansible disadvantages include the following:

  • It can be slow when collecting a large volume of information, which is why Nornir was developed.
  • Its functions are tailored more to device-specific configuration.

Use cases

Ansible is often used to configure preexisting systems. Network device automation is a strong point.


Terraform is an infrastructure as code (IaC) tool for creating, maintaining and decommissioning large data center infrastructure. The configurations are specified in a declarative language, HashiCorp Configuration Language, or HCL. As the configuration changes, Terraform determines the steps to transform an infrastructure to the new desired state. Think of Terraform as a cloud infrastructure management tool that works across multiple cloud providers, such as AWS, Microsoft Azure and Google Cloud Platform. It is ideal for the full lifecycle of data center infrastructure.

Terraform has no GUI, which might be considered a liability, but isn't. The declarative language is ideal for working in a code repository with version control, which is necessary for IaC. Too many systems with graphical interfaces results in a complex maze of screens with choices and dialog boxes that could be accomplished with a few lines of configuration syntax.

A helpful feature of Terraform is plan phase, which shows what changes would occur without actually performing them. Think of it as a test drive of a proposed change. The output enables teams to verify that the changes are what they intended to happen and that the desired end state is achieved.


Below are some of the benefits of Terraform:

  • Teams can provision and maintain infrastructure, independent of cloud provider.
  • It integrates multiple cloud services with external functions, like email and DNS.
  • Plan phase provides visibility into changes before applying them.


Terraform's declarative configuration language can be a barrier to adoption.

Use cases

Terraform can be used to provision and maintain cloud-based infrastructure. It is particularly well suited for automating changes to a larger infrastructure that consists of multiple components.

Ansible vs. Terraform vs. Vagrant
Compare Ansible, Terraform and Vagrant, looking at pros and cons as well as use cases.


Vagrant is most often used to automate the consistent creation of a small set of VMs. The most common use case is to replicate a development environment among multiple developers who need to guarantee development consistency. This is particularly important for consistency in software library versions, environment variables and versions of supporting software.

Ansible, Terraform and Vagrant each perform automation in some way, but their functionality is decidedly different.

Vagrant can incorporate other automation tools, like Ansible, Puppet or Chef, to perform specific VM configuration tasks. Developers specify the software version and elements they want in the environment, and Vagrant performs the actions necessary to create a VM with that configuration. Other developers can use the same Vagrant configuration file to quickly replicate the VM.

Consistency of the development environment is critical for eliminating bugs related to differences between each software developer's environment. Vagrant is also valuable for quickly and consistently instantiating software test systems, enabling developers to easily fire up test systems when checking new features and bug fixes.


Below are some of the benefits of Vagrant:

  • Teams can easily create standard environments for development and testing.
  • Many software development organizations have adopted it.


Vagrant is not well suited for handling changes to infrastructure.

Use cases

Vagrant is most often used to create consistent development and testing VM environments.

Choosing a tool

Ansible, Terraform and Vagrant each perform automation in some way, but their functionality is decidedly different. It would not be unusual to see all three being used within an organization: Ansible for network configuration management, Terraform to manage cloud infrastructure across one or more cloud providers, and Vagrant for software development and test platform standardization.

As always, it is best to select the tool that matches your business requirements.

Dig Deeper on Network management and monitoring

Unified Communications
Mobile Computing
Data Center