Skip to content

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:

# GitHub Container Registry
docker run -it --pull=always -p 3000:3000 ghcr.io/nirgeier/ansiblelabs

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

🌐 Launch on Killercoda

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 Shell button below:

Open in Cloud Shell

  • 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:

  1. Lab 000: Setup
  2. Lab 001: Verify Ansible
  3. Lab 002: No Inventory
  4. Lab 003: Modules
  5. Lab 004: Playbooks

🟡 Intermediate Path

For those comfortable with the basics:

  1. Lab 005: Facts
  2. Lab 009: Roles
  3. Lab 010: Loops & Conditionals
  4. Lab 011: Jinja2 Templating
  5. Lab 014: Playbook Variables
  6. Lab 015: Handlers & Blocks
  7. Lab 019: Ansible Vault
  8. Lab 020: Tags

🔴 Advanced Path

For experienced Ansible engineers:

  1. Lab 021: Ansible with Docker
  2. Lab 024: Ansible Lint
  3. Lab 025: CI/CD Jenkins
  4. Lab 026: CI/CD GitHub Actions
  5. Lab 028: Custom Modules
  6. Lab 029: Advanced Execution
  7. Lab 033: Best Practices
  8. Lab 034: Security Hardening
  9. 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=0 on 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!