Learn Ansible by running it. Work through the lessons in order and you'll go from your first ad-hoc command to reusable roles and encrypted secrets — inventory, playbooks, modules, variables, templates, handlers, roles, and Vault. Every lesson is YAML you write and commands you run.
This course teaches Ansible by configuring a real machine — your own — so you need comfort in a terminal and with SSH and YAML. You do NOT need remote servers: every example runs against localhost. New to the command line? Do the Linux course first.
Before you start
Ansible's control node runs on Linux or macOS — there is no native Windows build. Install it for your OS, then confirm it works. No remote servers needed; the course manages localhost.
Windows (via WSL)
Use WSL — run Ansible inside Ubuntu, not PowerShell.
wsl --install
# then inside Ubuntu:
sudo apt update && sudo apt install ansiblemacOS
Via Homebrew.
brew install ansibleLinux
Via apt (or your package manager).
sudo apt update && sudo apt install ansibleConfirm it works, then create a folder and a one-line inventory:
ansible --version
mkdir ansible-lab
cd ansible-lab
echo "localhost ansible_connection=local" > inventory.ini
ansible all -m ping -i inventory.iniInventory & Ad-hoc Commands
Tell Ansible which machines to manage with an inventory, then run one-off commands across them — starting with your own machine, so you need no remote servers.
Your First Playbook
Move from one-off commands to a playbook — a YAML file describing the desired state of a machine — then run it and watch Ansible report what changed.
Tasks & Modules
Modules are the verbs of Ansible. Use the everyday ones — file, copy, package, service, lineinfile — and understand why a real module beats the raw command module.
Variables & Facts
Make playbooks reusable with variables — defined inline, in files, and per host or group — and use facts, the data Ansible auto-discovers about each machine.
Templates with Jinja2
Generate real configuration files from variables and facts using the template module and Jinja2 — loops, conditionals, and filters that turn data into config.
Conditionals & Loops
Make tasks decide and repeat — run a task only when a condition holds with when, and act on every item in a list with loop.
Handlers & Idempotency
Restart a service only when its config actually changed, using handlers and notify — the pattern that makes Ansible runs both correct and minimal.
Roles
Roles are how you organize and reuse Ansible at scale — a standard directory layout that bundles tasks, variables, templates, and handlers into a shareable unit.
Vault — Managing Secrets
Keep passwords, keys, and tokens encrypted at rest with Ansible Vault — encrypt whole files or single values, edit them safely, and decrypt only at run time.
Running Playbooks in Practice
Run playbooks the way operators do — target a subset of hosts, run only tagged tasks, dry-run with check and diff, and configure Ansible with ansible.cfg.