Microsoft Certified: Azure DevOps Engineer Expert Intermediate — Quiz 2
Microsoft Certified: Azure DevOps Engineer Expert Intermediate — Quiz 2 — Study Guide
Configuration Management Tools: Puppet, Ansible, and Chef
Configuration management is the backbone of modern DevOps practice. Without it, managing hundreds or thousands of servers becomes a chaotic, error-prone nightmare. Tools like Puppet, Ansible, and Chef let you define exactly how your infrastructure should look — and automatically enforce that vision at scale. Whether you're preparing for the Azure DevOps Engineer Expert exam or working in the field, understanding these tools is essential for building reliable, auditable, and secure systems.
What Is Configuration Management?
Configuration management is the practice of automating the setup, maintenance, and enforcement of system configurations across your infrastructure. Instead of manually SSH-ing into servers and running commands, you write code that describes your desired state — what the system *should* look like — and the tool makes it so.
Key Concepts
Analogy: Think of desired state like a recipe. If you want a chocolate cake, the recipe defines exactly what ingredients and steps are needed. Idempotency means if the cake is already baked, you don't bake it again.
Puppet
Puppet uses a declarative approach — you describe *what* you want, not *how* to get there. Puppet figures out the steps.
Puppet Master and Agents
Manifests and Modules
.pp files). They define resources like packages, files, and services.# Example Puppet manifest
package { 'nginx':
ensure => installed,
}service { 'nginx':
ensure => running,
enable => true,
}
Hiera and Data Management
Hiera is Puppet's built-in data management tool. It separates configuration data from code, allowing you to store environment-specific values (like server names or passwords) outside your manifests. This supports secrets management by keeping sensitive data out of your codebase.
Roles and RBAC
Puppet supports RBAC (Role-Based Access Control) to control who can manage which nodes or environments. Roles group classes together to describe what a node does (e.g., a "web server" role includes nginx, firewall rules, and monitoring).
Ansible
Ansible takes a simpler, agentless approach. It connects to nodes via SSH and executes tasks defined in playbooks.
Playbook Structure
A playbook is a YAML file that defines a series of plays, each targeting a group of hosts and listing tasks to run.
# Example Ansible Playbook
name: Configure web servers
hosts: webservers
become: true
tasks:
- name: Install nginx
ansible.builtin.package:
name: nginx
state: present - name: Ensure nginx is running
ansible.builtin.service:
name: nginx
state: started
enabled: true
Key Ansible Modules
| Module | Purpose |
|---|---|
package | Package management — install/remove software |
file | File module — manage files and directory creation |
user | User module — user management (create/delete users) |
template | Template resource — generate dynamic configuration files |
service | Manage services, including service restart |
Handlers
Handlers are special tasks that only run when notified by another task. A common use case is service restart — if a config file changes, notify a handler to restart the service.
tasks:
- name: Copy nginx config
ansible.builtin.template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
notify: Restart nginxhandlers:
- name: Restart nginx
ansible.builtin.service:
name: nginx
state: restarted
Attributes and Data Storage
Ansible uses variables and inventory files for data storage and attributes (node-specific values). Like Hiera in Puppet, Ansible Vault handles secrets management by encrypting sensitive variables.
Chef
Chef uses a procedural approach — you write recipes in Ruby that describe *how* to configure a system step by step.
Cookbooks and Recipes
# Example Chef Recipe
package 'nginx' do
action :install
endservice 'nginx' do
action [:enable, :start]
end
Procedural vs. Declarative
| Approach | Tool | Description |
|---|---|---|
| Declarative | Puppet | Define the desired end state; tool determines how |
| Procedural | Chef | Write step-by-step instructions for how to configure |
| Hybrid | Ansible | Mostly declarative tasks, executed procedurally |
Security and Automation at Scale
All three tools support security best practices:
Key Takeaways
file, user, and template cover most configuration needs.