Ansible is an open-source automation tool for configuring servers, deploying applications and running repeatable operations tasks. It is agentless: a control node connects to managed machines over SSH, or WinRM for Windows, and runs small units of work called modules. You list your machines in an inventory and describe the desired state in YAML playbooks, such as a package installed or a service running. Most modules are idempotent, so running a playbook twice changes nothing the second time. Variables, Jinja2 templates and roles let the same code serve many environments. Learnr builds a personalized Ansible course taught in bite-sized, interactive lessons.
How to learn Ansible, step by step
- Build a small lab of throwaway machines. Create two or three Linux virtual machines or containers you can break freely. Set up SSH key login from your control node, since Ansible depends on reliable SSH access.
- Write an inventory and run ad hoc commands. List your hosts in groups in an INI or YAML inventory and run ansible all -m ping to confirm connections. Then try ad hoc commands with the package or service modules to see modules in action.
- Write your first playbook. Install and start a web server with a playbook that uses apt or dnf, copy and service modules. Run it twice and confirm the second run reports no changes, which is idempotence in practice.
- Add variables, templates and handlers. Move values into group_vars, render a config file with the template module, and use notify with a handler to restart the service only when that file changes. Read gathered facts to adapt tasks per host.
- Refactor into roles and preview changes. Split your playbook into a role with tasks, templates and defaults folders. Run with --check and --diff before applying changes, and lint your code with ansible-lint.
- Handle secrets and automate a real stack. Encrypt passwords with Ansible Vault and automate a full app deployment with a database and web tier. A short Learnr lesson each day keeps module names and playbook syntax fresh.
What you'll learn
- Write inventories and run ad hoc commands against groups of hosts
- Build playbooks with tasks, modules, variables and handlers
- Generate configuration files with Jinja2 templates
- Organize automation into reusable roles and collections
- Protect secrets with Ansible Vault and test changes with check mode
How long does it take to learn Ansible?
If you know Linux administration, you can write useful playbooks in 1 to 2 weeks at 5 hours a week. Designing clean roles, managing many environments and testing automation well takes 2 to 3 months of real use.
What you need before you start
Comfort with the Linux command line, SSH and basic system administration such as installing packages and managing services. Familiarity with YAML syntax helps but is quick to learn.
Common mistakes to avoid
- Using the shell or command module for everything instead of purpose-built modules, which loses idempotence and clear change reporting.
- Storing passwords and API keys in plain text variables. Encrypt them with Ansible Vault or pull them from a secrets manager.
- Running new playbooks straight against production. Test on lab machines and use check mode with diff to preview what will change.
How Learnr builds your course
Type your topic
Tell Learnr you want to learn Ansible, or get as specific as you like.
Get a personalized course
Learnr instantly builds a full Ansible course tailored to your goal and skill level.
Learn and level up
Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.
Ansible questions, answered
What is the difference between Ansible and Terraform?
Terraform mainly provisions infrastructure such as networks and virtual machines, while Ansible mainly configures what runs on them. Many teams use Terraform to create servers and Ansible to set them up.
Do I need to know Python to use Ansible?
No. Playbooks are YAML. Ansible is written in Python and managed hosts usually need Python installed, but you only write Python if you build custom modules or plugins.
Does Ansible work with Windows?
Yes. Ansible manages Windows hosts over WinRM or SSH with Windows-specific modules, though the control node itself runs on Linux or macOS.
Explore more courses
More programming and tech courses
- Learn CI/CD
- Learn MySQL
- Learn Nginx
- Learn Web Scraping
- Learn Cryptography
- Learn Network Security
- Learn Coding
- Learn Python
See all programming and tech courses
Ready to learn Ansible?
Start your free, personalized Ansible course in seconds. It will be typed in and ready when you get there.
Start learning AnsibleFree to start. No credit card.