Why Ansible? A comparative view: Ansible vs Puppet vs Terraform

Why Ansible? A comparative view: Ansible vs Puppet vs Terraform

Play this article

DevOps is a culture where everyone in an organisation gets engaged with each other to achieve the common goal of ensuring faster and smoother software/product delivery. By each passing day DevOps is gaining great acceptance amongst the industry players at different levels whether it's a big enterprise or a startup company.

Along with that the Infrastructure as Code (IaC) solutions aka configuration management and orchestration tools such as Ansible, Puppet and Terraform are also witnessing a huge demand and popularity.

All these tools helps in deploying applications and infrastructure. Ansible and Puppet are the tools for configuration management (abbreviated as CM) whereas Terraform is a service orchestration and provisioning tool.

Let's go through their official definitions.

What is Ansible?

As per official documentation Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.

What is Puppet?

As per official documentation Puppet is the industry standard for IT automation. Manage and automate more infrastructure and complex workflows in a simple, yet powerful way.

What is Terraform?

As per official documentation Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Before we dig deeper we must understand the terms Orchestration and Configuration management.

What is Orchestration and Configuration Management?

Orchestration it is mainly concerned with automating the execution of a workflow – of a process. Simple automation can't get you process optimization. Orchestration tools such as Terraform can be used for not only just server provisioning, but also other tasks such as databases, caches, load balancers, queues, monitoring, subnet configuration, firewall settings, routing rules, SSL certificates, and so on, mainly on public cloud infrastructure. Orchestration tools provides an opportunity to streamline and to optimize deployment processes.

Terraform is designed to provision the server instances themselves, leaving the job of configuring those servers to other tools.

Configuration management in a simple term is the process where we ensure that all the servers and applications meets the desired state. It can be achieved through a set of processes and tools. By using CM tools we make sure that a system performs on expected lines.

To make IT deployments faster, scalable, incremental, repeatable, predictable, and maintainable one uses CM tools such as Ansible and Puppet.

Please note that we should not get confused between these two terms (automate and orchestrate) because both shares some benefits, at the same time these are inter-dependent and works together to achieve common goals and works in a combination thereof.

All the DevOps tools which we use in our day to day life uses two approaches for writing manifests in order to achieve the desired outcomes - Procedural and Declarative. Let's understand what are these.

Procedural vs. Declarative Language

declarative-procedulural.png

In Procedural approach you define the whole process or we can say the exact steps in the code to achieve the expected results whereas with Declarative approach you just declare what exactly is needed, not the process by which the result is achieved.

Ansible uses procedural style where you write the code that specifies, step-by-step tasks in order to achieve some desired end state at the same time Puppet uses both approaches.

Whereas orchestration tools like Terraform and CloudFormation by AWS uses declarative methods where you write code that specifies your desired end state. For example if you needed 10 EC2 instances, 1 load balancer etc. you use the declarative approach and get exactly the same number of resources once the code has been executed.

A comparison among Ansible, Puppet and Terraform

Below table lists out the differences and similarities between Ansible, Puppet and Terraform based on different factors:

CharacteristicAnsiblePuppetTerraform
PAID/Open SourceOpen Source/PAIDOpen Source/PAIDOpen Source/PAID
Tool TypeConfiguration ManagementConfiguration ManagementOrchestration/provisioning
Agent InstallationNo agents required to communicate with clientsAgent needs to be installedTerraform also does not require any extra agent to install
Ease of Setup and UseAnsible is simpler to install and useIts initial setup is difficultTerraform too is simpler to install and use
ArchitectureNo concept of Master server, communicates over SSH protocolMaster-Slave ArchitectureTerraform is also master less. It communicates with the different providers using API
Push vs PullFollows a “push” workflowFollows a “pull” workflowFollows a “push” workflow
GUI supportAnsible free version UI is less developed , enterprise version offers a UI but that too has syncing issuesVery interactive GUINo official GUI. Only third party GUIs are available.
Process definition approachProceduralProcedural/DeclarativeDeclarative
Process OrderingTop-to-Bottom ordering of resources defined in playbookRandom ordering of resources defined in cookbookRandom ordering of resources defined in Terraform script
Cloud supportworks on all cloudsworks on all cloudsworks on all clouds
SyntaxYAMLRuby, Puppet DSLHCL (Terraform Language)
Template LanguageJinja2Ruby’s ERBHCL (Terraform Language)
DependenciesSSH and PythonRuby and dependent packagesDepends on providers to manage different platforms
IdempotencySupportsSupportsSupports
Community SupportLarge (lacks in Windows support)Large (most mature Windows support)Large
Maturity LevelMediumMediumMedium
PricingBasic version is free and open source, Enterprise support costs ~ $10,000 per year for up to 100 nodesBasic version is free and open source. It costs ~ $100 per node for the standard editions and $199 per node for the premium editionBasic version is free and open source. Pricing can be found here.

Which one I should go with?

Honestly speaking it totally depends on one's own requirements.

If we talk about the real world IT organizations then you will find almost all the tools being utilized there as they never rely on one specific tool instead use combination of different tools to achieve the desired results. That brings more flexibility and stability.

I personally use Terraform for orchestration/provisioning on public cloud platforms (as this is what it was created for) and Ansible for all kind of configuration management.

My mantra is "Use what is best, suites your requirements and originally created for the tasks you want to perform."

There are people who prefer to use one tool for everything and that's perfectly fine as long as it servers their purpose!

Conclusion

I hope you have a basic idea about all these three tools we have discussed above and be clear that nothing is perfect as all of them have their own benefits and limitations. Chose what's best suites you.

That's all for now. Hope you like the article. Stay Tuned and don't forget to subscribe for more.

Thank you. Happy learning!

Did you find this article valuable?

Support Learn Code Online by becoming a sponsor. Any amount is appreciated!