Understanding Ansible, Puppet, and Chef: A Beginner’s Guide to Configuration Management

Managing servers and applications can be tricky, especially when you have many machines to handle at the same time. Configuration management tools help make this easier. Tools like Ansible, Puppet, and Chef let you automate tasks, so you don’t have to do everything manually. You can install software, update settings, and manage multiple servers with just a few commands. In this blog, we will explain these three tools in simple terms, how they work, and what makes each one different. This guide is for anyone who wants to understand server automation without getting lost in technical jargon.
What is Configuration Drift?
When managing multiple servers, one common challenge IT teams face is keeping all servers exactly the same. Over time, small changes like updating software on one server but not the others can cause the servers to differ from each other. This problem is called configuration drift.
Configuration drift can lead to issues such as applications not working correctly, inconsistent security settings, and harder troubleshooting because each server behaves slightly differently.
This is where configuration management tools like Ansible, Puppet, and Chef become valuable. They help prevent configuration drift by automatically keeping all your servers consistent, so you don’t have to manually check and fix every change.
What is Configuration Provisioning?
After understanding configuration drift, the next important concept is configuration provisioning. Provisioning is the process of setting up servers and installing everything they need like software, settings, and user accounts so they are ready to use.
Think of it like setting up a new office. You need desks, chairs, computers, and internet for each room. Provisioning a server is similar. You make sure it has all the tools it needs to work properly.
Configuration management tools like Ansible, Puppet, and Chef make provisioning easier. Instead of manually installing and configuring everything on each server, you can write instructions once, and the tool sets up all your servers the same way. This saves time, reduces errors, and ensures consistency across your infrastructure.
Configuration Management Tools
Now that we understand configuration drift and provisioning, it’s time to look at configuration management tools. These tools help automate the setup, management, and maintenance of servers. Instead of manually configuring each server, you write instructions once, and the tool applies them to all your servers.
The main benefits of these tools are:
Consistency: They keep all servers configured the same way, preventing configuration drift.
Automation: They save time by automatically installing software, updating settings, and performing routine tasks.
Scalability: They make it easy to manage a few servers or hundreds without extra effort.
Repeatability: Once a setup is defined, it can be reused anytime you need new servers.
The three most popular tools in this space are Ansible, Puppet, and Chef. Each has its own way of managing servers, but all aim to make IT automation simpler and more reliable.
Ansible: Automating Configurations Easily
Ansible is a configuration management tool owned by Red Hat and written in Python. It is agentless, which means you don’t need to install any special software on the servers or devices you want to manage. Ansible uses SSH to connect to devices and make changes, which keeps things simple and lightweight. It works using a push model, meaning you push the instructions from your control machine to the managed devices.
After setting up Ansible, you organize your automation tasks using several types of text files: Playbooks, Inventory, Templates, and Variables. Let’s look at each of these in more detail:
Inventory
The inventory is a list of servers or devices Ansible will manage. You can group servers logically to make management easier. For example:
[webservers]
192.168.1.10
192.168.1.11
[dbservers]
192.168.1.20
Here, we have two groups: webservers
and dbservers
. Ansible knows which servers to manage based on these groups.
Playbooks
Playbooks are the heart of Ansible. They are written in YAML and describe the tasks you want Ansible to perform. For example, to install Nginx on webservers:
- hosts: webservers
become: yes
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
This playbook tells Ansible to connect to all servers in the webservers
group and ensure Nginx is installed.
Variables
Variables let you store values that you can reuse in playbooks or templates. For example, instead of hardcoding the package name, you can use a variable:
vars:
web_package: nginx
tasks:
- name: Install web server
apt:
name: "{{ web_package }}"
state: present
This makes your playbooks flexible and easier to maintain.
Templates
Templates allow you to create dynamic configuration files using variables. Ansible uses Jinja2 syntax for templates. For example, an Nginx configuration template could look like:
server {
listen 80;
server_name {{ domain_name }};
root /var/www/{{ domain_name }};
}
When you run the playbook, Ansible replaces {{ domain_name }}
with the value you define in variables.
Puppet: Managing Configurations with a Pull Model
Puppet is a configuration management tool written in Ruby. It is typically agent-based, meaning you need to install Puppet software (agent) on the devices you want to manage. Not all devices, such as some Cisco devices, support a Puppet agent. In cases where an agent cannot be installed, Puppet can run agentless using a proxy agent on an external host. The proxy agent connects to the managed devices via SSH and communicates with the Puppet Master.
Puppet uses a pull model, meaning the agents regularly check in with the Puppet Master to see what configurations they should apply. The default communication happens over TCP port 8130.
Key Files in Puppet
Puppet uses its own declarative language for configuration instead of YAML. The main text files required on the Puppet Master are manifests and templates.
Manifest:
Manifests describe the desired state of your devices or servers. For example, to ensure Nginx is installed and running:package { 'nginx': ensure => installed, } service { 'nginx': ensure => running, enable => true, }
Puppet reads the manifest and applies these configurations to the agents.
Template:
Templates allow dynamic configuration files. Puppet uses ERB (Embedded Ruby) syntax. For example, an Nginx configuration template could look like:server { listen 80; server_name <%= @domain_name %>; root /var/www/<%= @domain_name %>; }
Puppet replaces
<%= @domain_name %>
with the actual value defined in the manifest or Hiera data.
Puppet is ideal for environments where you want consistent configurations across many servers. Once you understand manifests and templates, you can automate most server configuration tasks reliably.
Chef: Automating Infrastructure with Recipes
Chef is a configuration management tool written in Ruby. Like Puppet, it is agent-based, which means you need to install a Chef client on the devices you want to manage. Not all Cisco devices support Chef agents. Chef also uses a pull model. In this setup, the Chef client regularly checks in with the Chef server to pull down configurations. The communication happens over TCP port 10002.
Chef uses a Domain-Specific Language (DSL) based on Ruby to define configurations. Instead of YAML or a proprietary language, you write instructions in Ruby syntax. Chef organizes its automation into several text files: Resources, Recipes, Cookbooks, and Run-lists.
Key Files in Chef
Resources:
Resources are the basic building blocks in Chef. A resource describes a specific piece of configuration, such as installing a package or starting a service. Example:package 'nginx' do action :install end service 'nginx' do action [:enable, :start] end
Recipes:
Recipes are collections of resources that describe how a system should be configured. For example, a recipe to set up a web server might include resources to install Nginx, configure files, and start the service.Cookbooks:
Cookbooks are collections of recipes, templates, and other files grouped together. They organize configurations in a reusable way. For example, you might have awebserver
cookbook that contains all the recipes and templates needed for web server deployment.Run-list:
The run-list is the order in which recipes are applied to a node (server). For example, you might define that a server should first apply thewebserver
recipe and then thesecurity
recipe. The run-list ensures configurations are applied in the correct sequence.
Example
A simple recipe to install and configure Nginx:
package 'nginx' do
action :install
end
service 'nginx' do
action [:enable, :start]
end
file '/var/www/html/index.html' do
content 'Hello from Chef!'
end
This recipe installs Nginx, ensures it is running, and creates a simple HTML file for the web page.
Comparison of Ansible, Puppet, and Chef
Feature | Ansible | Puppet | Chef |
Language | YAML (playbooks) | DSL based on Ruby (manifests/templates) | DSL based on Ruby (recipes/cookbooks) |
Architecture | Agentless (uses SSH/WinRM) | Agent-based | Agent-based |
Model | Push model (control node pushes) | Pull model (agents pull from Puppet Master) | Pull model (agents pull from Chef Server) |
Server Port | No special port (uses SSH, TCP 22) | TCP 8140 | TCP 10002 |
Ease of Use | Simple, beginner-friendly | More complex than Ansible | Complex, requires Ruby knowledge |
Scalability | Medium (good for small to medium) | High (enterprise-level scalability) | High (enterprise-level scalability) |
Device Support | Supported by Cisco | Not all Cisco devices support Puppet | Not all Cisco devices support Chef |
Strengths | Easy setup, no agents, simple YAML | Strong automation for large infrastructures | Flexible, integrates well with cloud |
Summary
Ansible: Best for beginners and quick setups. It’s agentless, uses YAML, and works well for simple automation.
Puppet: More complex, agent-based, and scalable. Uses Ruby DSL with manifests and templates. Best for large-scale enterprise automation.
Chef: Also agent-based and scalable. Uses Ruby DSL with resources, recipes, and cookbooks. Good for cloud integration and DevOps pipelines.
Wrap Up
Ansible, Puppet, and Chef all fall under configuration management tools, but each fits different needs.
If you want simplicity and ease of learning, go with Ansible.
If you need enterprise-level automation with strong scalability, Puppet is a solid choice.
If your focus is cloud environments and DevOps integration, Chef might be the better option.
In networking (like with Cisco devices), Ansible is the most widely supported, while Puppet and Chef have limited support. Choosing the right tool depends on the size of your infrastructure, your team’s skillset, and your automation goals.
Subscribe to my newsletter
Read articles from Pits directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
