Ansible Assignments — Automate. Orchestrate. Scale.

Move from ad-hoc commands to production-ready automation. Each topic-wise set includes 20 Basic, 20 Intermediate, and 10 Advanced questions so learners can practice deliberately and level up fast.

Your six attached assignments span: core concepts & ad-hoc, playbooks & tasks, modules, templates & Galaxy, roles & reusability, inventory, Vault & strategies, and CI/CD & cloud automation.

Why practice with these assignments?

  • Go beyond theory—inventory → ad-hoc → playbooks → roles → CI/CD with realistic tasks.
  • Build production habits: handlers, variables, conditionals, loops, tags, templates, Galaxy roles/collections.
  • Get ops-ready with dynamic inventory, Vault, execution strategies, and error handling.
  • Ship end-to-end: Docker/Kubernetes + AWS provisioning and app deploys integrated with Jenkins/GitLab CI.

How it works

  • Open any assignment and attempt questions in order: Basic → Intermediate → Advanced.
  • Run locally against VMs/containers or cloud instances; verify outputs and idempotency.
  • Keep a short “what I learned” note per task—syntax + reasoning + gotchas.
  • For sensitive data, use Vault rather than plaintext; prefer dynamic inventory where appropriate.

What you’ll achieve

  • Confident use of inventories, ad-hoc commands, facts, and ansible.cfg.
  • Fluent playbook authoring with variables, conditionals, loops, handlers, and tags.
  • Practical mastery of core modules, Jinja2 templates, Galaxy roles/collections, and custom modules.
  • Reusable automation with roles, defaults, handlers, vars_files, and role composition.
  • Operational confidence with Vault, dynamic inventory, strategies, retries, and delegation.
  • CI/CD & cloud workflows across Docker, Kubernetes, AWS with pipeline integration.

Browse the Assignments

  • Assignment 1 — Core Concepts & Ad-Hoc: install Ansible, inventories, ad-hoc ping/uptime/disk, facts, ssh keys, ansible.cfg.
  • Assignment 2 — Playbooks & Tasks: install/configure services, variables, handlers, tags, multi-play files, when/loops, groups.
  • Assignment 3 — Modules, Templates & Galaxy: file/package/service/user/copy/template, Jinja2, Galaxy roles/collections, custom modules.
  • Assignment 4 — Roles & Reusability: role scaffolding, defaults/vars, include/import tasks, handlers, vhosts/db users, multi-role stacks.
  • Assignment 5 — Advanced Features: dynamic inventories (AWS/GCP/Azure/Docker/K8s), Vault, strategies (linear/free/serial), async/poll, until/retries.
  • Assignment 6 — CI/CD & Cloud: Nginx/MySQL/Docker/K8s deploys, AWS infra (EC2/S3/VPC/RDS), rollbacks, scaling, Jenkins/GitLab CI integration.

Tips for success

  • Prefer idempotent modules over shell commands; assert changes with changed_when/check_mode when helpful.
  • Start small: run on a single host (-l) before widening scope; use tags to focus runs.
  • Keep secrets in Vault and inventory outside source control; document how to decrypt.
  • Measure speed with forks/pipelining/SSH settings, and pick the right strategy for your rollout.
  • Reuse via roles and collections; version them just like app code.

Ready to build real confidence in HTML? Pick a set below and start solving!

FAQs

Q1. Which Ansible version should I use?
A current stable Ansible/ansible-core works for all tasks. The exercises focus on widely used modules, playbook features, roles/collections, and Vault—no bleeding-edge plugins required.

Q2. How do I structure my repository?
Keep inventories, group_vars/host_vars, roles/, and playbooks/ at the top level. Use roles for reuse and keep environment-specific variables in vars files (optionally Vault-encrypted).

Q3. When should I use ad-hoc commands vs playbooks?
Use ad-hoc commands for quick checks (ping, uptime, packages). Use playbooks for repeatable, idempotent changes with handlers, conditionals, and variables.

Q4. Why are my playbooks re-running tasks that shouldn’t change?
Prefer idempotent modules (package, user, service), use the correct state, and ensure templates/files don’t rewrite unchanged content. Add handlers to restart only when notified.

Q5. Roles vs collections—what’s the difference?
Roles bundle tasks, handlers, templates, and vars for reuse in playbooks. Collections package roles and plugins/modules for distribution (e.g., Galaxy’s community.general). You’ll practice both.

Q6. How do I manage secrets safely?
Encrypt with Ansible Vault (variable files or entire playbooks). Run with --ask-vault-pass or a password file, and never commit plaintext secrets.

Q7. What inventory should I start with?
Begin with static inventories (INI/YAML) for local VMs. Move to dynamic inventories for AWS, GCP, Azure, Docker, or Kubernetes as environments grow.

Q8. My long runs are slow—how do I speed them up?
Increase forks, enable pipelining, and tune SSH. Pick strategy: free for parallelism or serial for safe rolling updates. Use async/poll for long tasks.

Q9. Can I integrate with Jenkins or GitLab CI?
Yes—call ansible-playbook from your pipeline, pass inventory/Vault, and publish artifacts/logs. The CI assignments include working examples.

Q10. How do I verify everything worked?
Check return codes, module results (changed/failed), service status, and application reachability. Use facts, register variables, and assert. Rerun in check mode to preview changes.