Ansible Labs¶
📋 Lab Overview¶
- Welcome to the hands-on Ansible labs!
- This comprehensive series of 36 labs guides you from basic setup through advanced topics like custom modules, CI/CD integration, security hardening, and cloud provisioning.
Usage¶
- There are several ways to run the AnsibleLabs Labs.
- Choose the method that works best for you.
Using Docker is the easiest way to get started locally with the labs:
Prerequisites:
- Docker and Docker Compose installed on your system
- No additional setup required
- The easiest way to get started with the labs
- Learn in your browser without any local installation
Benefits:
- No installation required
- Pre-configured environment
- Works on any device with a web browser
- All tools pre-installed
For those who prefer to run it directly on their machine:
# Clone the repository
git clone https://github.com/nirgeier/AnsibleLabs
# Change to the Labs directory
cd AnsibleLabs/Labs
# Start with the setup lab
cd 000-setup
# Follow the instructions in the README of each lab
cat README.md
Prerequisites:
- A Unix-like operating system (Linux, macOS, or Windows with WSL)
- Basic command-line tools
- Google Cloud Shell provides a free, browser-based environment with all necessary tools pre-installed.
- Click on the
Open in Google Cloud Shellbutton below:
- The repository will automatically be cloned into a free Cloud instance.
- Use CTRL + click to open it in a new window.
- Follow the instructions in the README of each lab.
Benefits:
- No local installation required
- Pre-configured environment
- Works on any device with a web browser
- All tools pre-installed
- Free tier available
🗂️ Available Labs¶
Beginner Track - Foundation¶
| Lab | Topic | Description |
|---|---|---|
| 000 | Setup | Set up the lab environment with an Ansible controller and 3 Linux servers in Docker |
| 001 | Verify Ansible | Create and test ansible.cfg, inventory, and ssh.config files |
| 002 | No Inventory | Understand inventory by showing what happens without it |
| 003 | Modules | Learn about Ansible modules and ad-hoc commands |
| 004 | Playbooks | Introduction to Ansible playbooks, structure, and basic usage |
Intermediate Track - Core Skills¶
| Lab | Topic | Description |
|---|---|---|
| 005 | Facts | Gather and use Ansible facts in playbooks |
| 006 | Git | Create a playbook to install Git and clone repositories |
| 007 | Create User | Create a playbook for creating users on remote systems |
| 008 | Challenges | Challenge lab combining user creation and Git operations |
| 009 | Roles | Ansible roles - structure, creation, and usage |
| 010 | Loops & Conditionals | Loops and conditional statements in playbooks |
| 011 | Jinja2 Templating | Jinja2 for dynamic configuration files |
| 012 | Host & Group Variables | host_vars/, group_vars/, and variable precedence |
| 013 | Ad-Hoc Commands | Run one-off tasks without writing a playbook |
| 014 | Playbook Variables | Define, pass, register, and transform variables |
| 015 | Handlers & Blocks | Event-driven task execution and error handling |
| 016 | File Modules | copy, template, lineinfile, blockinfile, fetch |
| 017 | Package & Service Modules | apt, yum, package, pip, service, systemd |
| 018 | Galaxy & Collections | Ansible Galaxy, Collections, and FQCNs |
| 019 | Ansible Vault | Encrypt secrets with Ansible Vault |
| 020 | Tags | Control task execution with tags |
Advanced Track - Expert Topics¶
| Lab | Topic | Description |
|---|---|---|
| 021 | Ansible with Docker | Manage Docker containers, images, networks, and Compose |
| 022 | Debugging | debug module, verbosity, check mode, debugger keyword |
| 023 | Idempotency | Write idempotent tasks and verify with check mode |
| 024 | Ansible Lint | Code quality with ansible-lint and Molecule |
| 025 | CI/CD - Jenkins | Integrate Ansible with Jenkins pipelines |
| 026 | CI/CD - GitHub Actions | Run Ansible via GitHub Actions workflows |
| 027 | CI/CD - GitLab CI | Integrate Ansible with GitLab CI/CD |
| 028 | Custom Modules | Write custom Ansible modules in Python |
| 029 | Advanced Execution | Rolling updates, delegation, serial, run_once |
| 030 | AWX & AAP | AWX and Ansible Automation Platform overview |
| 031 | Facts Deep Dive | Custom facts, fact caching, and selective gathering |
| 032 | Plugins | Lookup, filter, and callback plugins |
| 033 | Best Practices | Project structure, naming conventions, performance |
| 034 | Security Hardening | SSH hardening, firewall, auditd, sysctl |
| 035 | Cloud Modules | AWS EC2, S3, Azure, dynamic cloud inventory |
🎯 Learning Paths¶
🟢 Beginner Path¶
Start here if you’re new to Ansible:
🟡 Intermediate Path¶
For those comfortable with the basics:
- Lab 005: Facts
- Lab 009: Roles
- Lab 010: Loops & Conditionals
- Lab 011: Jinja2 Templating
- Lab 014: Playbook Variables
- Lab 015: Handlers & Blocks
- Lab 019: Ansible Vault
- Lab 020: Tags
🔴 Advanced Path¶
For experienced Ansible engineers:
- Lab 021: Ansible with Docker
- Lab 024: Ansible Lint
- Lab 025: CI/CD Jenkins
- Lab 026: CI/CD GitHub Actions
- Lab 028: Custom Modules
- Lab 029: Advanced Execution
- Lab 033: Best Practices
- Lab 034: Security Hardening
- Lab 035: Cloud Modules
💡 Tips for Success¶
- Take your time: Don’t rush through the labs - understanding beats speed
- Run playbooks twice: Check for
changed=0on the second run (idempotency) - Read the error: Ansible errors are usually very descriptive - read them carefully
- Use
-vvv: Add verbosity when stuck to see SSH details and module output - Experiment: Modify examples, break things, fix them - that’s how you learn
- Commit your work: Use Git to track your playbooks as they evolve
🚀 Get Started¶
Ready to begin? Start with Lab 000: Setup!