CHAPTER 19
Real-World Ansible Projects
Updated: May 15, 2026
35 min read
# CHAPTER 19
Real-World Ansible Projects
1. Introduction
In the DevOps industry, theoretical knowledge and syntax memorization only get you to the interview. To secure the job, you must possess a demonstrated portfolio of functional automation. Employers want to see that you can synthesize Ansible's massive module library, dynamic inventories, templating engines, and security vaults into cohesive, production-grade architectures. In this chapter, we outline five robust, professional-grade Configuration Management projects. These projects are designed to prove your mastery of automation workflows, Linux administration, and secure infrastructure orchestration.2. Learning Objectives
By the end of this chapter, you will be able to:- Architect an automated, multi-tier LAMP stack deployment.
- Build a comprehensive Linux Server Hardening playbook.
- Orchestrate a multi-container Docker environment via Ansible.
- Design an end-to-end cloud provisioning and configuration workflow.
- Document and present infrastructure projects professionally for a portfolio.
3. Project 1: Automated LAMP Stack Deployment
The Goal: Prove you understand core package management, service orchestration, and templating. The Architecture:-
1.
Source: An Ansible project with a structured
roles/directory.
- 2. The Roles:
-
common: Updates the OS, sets the timezone to UTC, installshtopandcurl.
-
database: Installs MySQL, secures the root user, and uses Ansible Vault for the database password.
-
web: Installs Apache/Nginx, PHP, and uses thetemplatemodule to dynamically generate the VirtualHost configuration based on anansiblefactsIP address.
-
3.
The Proof: Create a video running
ansible-playbook site.yml. Show a completely blank Ubuntu VM transforming into a live web server. Refresh a browser pointing to the IP address to show the active PHP application.
4. Project 2: Secure Linux Server Hardening (DevSecOps)
The Goal: Prove you understand Zero-Trust architecture and secure system administration. The Architecture:- 1. Source: A highly modularized security playbook.
- 2. The Components:
-
Use
userandauthorizedkeyto deploy a non-root admin user with cryptographic SSH keys.
-
Use
lineinfilewithvalidate: visudoto safely configure sudo permissions.
-
Use
lineinfileto strictly enforcePasswordAuthentication noandPermitRootLogin noin the/etc/ssh/sshdconfigfile.
-
Use the
ufwmodule to enable the firewall, blocking everything except ports 22, 80, and 443.
- 3. The Proof: Provide the playbook code on GitHub. Document the execution output. Demonstrate attempting to SSH into the server using a password as root, proving that the Ansible automation successfully hardened the server to reject the connection.
5. Project 3: Docker Deployment Automation
The Goal: Prove you can bridge the gap between Configuration Management and Containerization. The Architecture:-
1.
Source: A playbook utilizing the
community.dockercollection.
- 2. The Components:
-
Install Docker and its Python dependencies via the
aptandpipmodules.
-
Create an isolated
dockernetwork.
-
Deploy a Redis cache
dockercontainer.
-
Deploy a Node.js/Python API
dockercontainerthat connects to the Redis network, injecting environment variables dynamically via the Ansible playbook.
-
3.
The Proof: Document the playbook execution. Run an ad-hoc command
ansible all -m shell -a "docker ps"to show the live containers running, proving the seamless orchestration of the container environment.
6. Project 4: Dynamic Cloud Infrastructure Orchestration
The Goal: Prove you understand Cloud APIs and dynamic inventories. The Architecture:-
1.
Source: A playbook utilizing the
amazon.awscollection.
- 2. The Components:
-
Use
ec2securitygroupto provision a firewall in AWS.
-
Use
ec2instanceto build an Amazon Linux 2 server in the cloud.
-
Use the
addhostmodule to dynamically register the newly minted AWS IP address into Ansible's in-memory inventory.
-
Use
waitforconnectionto wait for SSH to boot.
- Deploy a basic web application to the dynamically discovered server.
- 3. The Proof: Provide screenshots of the AWS Console showing the newly created EC2 instance and Security Group. Document the single terminal command that built the hardware and configured the software in one fluid motion.
7. Project 5: The Enterprise CI/CD Pipeline
The Goal: Prove you understand GitOps and automated deployment governance. The Architecture:- 1. The Infrastructure: Upload Project 1 (The LAMP Stack) to a GitHub repository.
- 2. The Components:
-
Write a
.github/workflows/deploy.ymlGitHub Actions file.
-
Implement
ansible-lintas a prerequisite step to validate YAML formatting.
- Securely inject an SSH private key using GitHub Secrets.
- Securely pass an Ansible Vault decryption key from GitHub Secrets to decrypt database passwords during execution.
-
Execute the playbook automatically against a test server upon a push to the
mainbranch.
- 3. The Proof: Provide the GitHub Actions configuration file. Take screenshots of a successful GitHub Actions run log, highlighting the linting pass, the secure execution, and the final "Play Recap" showing successful configuration.
8. How to Document Your Automation Portfolio
A DevOps portfolio must focus on *scale* and *consistency*.-
README Driven Development: Your repository
README.mdis your resume. Explain *how* to run the playbook. Detail exactly which variables the user needs to provide ingroup_vars.
- The "Why": Explain your architectural decisions. "I utilized a dynamic Jinja2 template rather than the copy module to allow the Nginx configuration to automatically bind to the specific VPC IP address of the target host."
-
Idempotency Proof: Explicitly document that your playbook is idempotent. Post a screenshot showing a second run returning exactly
changed=0, proving your code is safe for production.