Ansible
Agentless automation for configuration management, application deployment, and orchestration.
Documentation
| Guide | Description |
|---|---|
| Ansible Fundamentals | Inventory, playbooks, roles, modules, Vault, Jinja2, Galaxy, exercises |
| Playbook Examples | Real-world playbooks: nginx, Docker, KVM, Windows, Vault, Vagrant |
| Command Cheat Sheet | 80+ commands and modules — ad-hoc, playbook, vault, galaxy, debugging |
| Interview Questions | 38 questions from beginner to advanced with detailed answers |
Why Ansible?
- Agentless — Uses SSH, no agents to install
- YAML-based — Human-readable playbooks
- Idempotent — Safe to run multiple times
- Extensible — 3000+ modules available
Learning Path
- Start with fundamentals — inventory, playbooks, roles, modules, Vault
- Keep the cheat sheet handy — 80+ commands and modules
- Practice interview questions — 38 Q&A with detailed explanations
Key Concepts
| Concept | Description |
|---|---|
| Inventory | INI/YAML file with server information |
| Playbook | YAML file defining automation tasks |
| Role | Reusable collection of tasks, vars, templates |
| Module | Unit of work (e.g., apt, copy, service) |
| Vault | Encrypt sensitive data |
| Handler | Trigger service status changes |
| Facts | Global variables about the system |
Quick Start
---
- name: Configure web servers
hosts: webservers
become: yes
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Start nginx
service:
name: nginx
state: started
enabled: yes
# Run a playbook
ansible-playbook site.yml
# Check mode (dry run)
ansible-playbook site.yml --check
# Ad-hoc commands
ansible all -m ping
ansible webservers -m shell -a "uptime"
# Vault
ansible-vault encrypt secrets.yml
External Resources
| Resource | Description |
|---|---|
| Ansible Documentation | Official Ansible docs |
| Ansible Modules Index | Complete module reference |
| Configuration Management 101 | Writing Ansible Playbooks |
| Ansible with Docker | Using Ansible on Docker |
| Ansible Roles & Jenkins | Integration with Jenkins and EC2 |