Free tutorial · examples you run in the browser
Ansible Tutorial
Learn Ansible step by step: install Ansible, write inventory files, run ad-hoc commands, build playbooks with tasks and handlers, use variables and Jinja2 templates, organise code into roles, encrypt secrets with Vault, and deploy applications with rolling updates. Every example shows real Ansible commands and their output.
Getting Started
- Ansible Introduction — What Ansible is, how it works, and when to use it.
- Ansible Installation — Install Ansible on the control node and verify the setup.
- Ansible Inventory — List and group managed hosts in inventory files.
- Ansible Ad-hoc Commands — Run one-off tasks without writing a playbook.
- Ansible Configuration — Control Ansible behaviour with ansible.cfg and environment variables.
Playbooks
- Ansible Playbook Basics — Write and run a YAML playbook with tasks.
- Ansible Modules — Learn the most commonly used built-in modules.
- Ansible Handlers — Restart services only when configuration changes.
- Ansible Variables — Define, override and inspect variables in playbooks.
- Ansible Conditionals and Loops — Control task execution with when, loop, block and rescue.
Configuration Management
- Ansible Facts — Gather and use system information from managed nodes.
- Ansible Templates (Jinja2) — Generate config files that adapt to each host with Jinja2 templates.
- Ansible Roles — Package tasks, templates and variables into reusable roles.
- Ansible Galaxy — Install and manage community roles and collections.
- Ansible Vault — Encrypt secrets so they can be stored safely in version control.
Advanced Topics
- Ansible Error Handling — Control how Ansible responds to task failures.
- Ansible Performance — Speed up playbook execution with strategies, pipelining and caching.
- Ansible Testing — Lint, dry-run and test your automation before deploying.
- Ansible Rolling Updates — Deploy to a fleet gradually with zero downtime.
- Ansible Best Practices — Conventions and patterns for maintainable automation.