โ† Back to list

๐Ÿš€ Building a Real-World CI/CD Pipeline with Azure DevOps, Terraform & Ansible (EpicBook Project)

Modern software development is no longer just about writing code โ€” itโ€™s about automating deployment, infrastructure, and delivery pipelinesโ€ฆ

Aarti Jadhav ยท 2026-04-30 21:23 ยท 0 claps ยท 3.7 min read
#cicd #devops #iaac #azure-devops #cloud-computing
Open on Medium โ†—
Wiki topics: ๐Ÿ’ป ยท Programming โ˜๏ธ ยท DevOps & Cloud

๐Ÿš€ Building a Real-World CI/CD Pipeline with Azure DevOps, Terraform & Ansible (EpicBook Project)

Modern software development is no longer just about writing code โ€” itโ€™s about automating deployment, infrastructure, and delivery pipelines so applications can be shipped faster and more reliably.

In this blog, Iโ€™ll walk through how I built a complete CI/CD pipeline using Azure DevOps, Terraform, and Ansible to deploy a full-stack application called EpicBook using a real-world DevOps architecture.

๐Ÿงฉ Project Overview

This project follows an enterprise-style two-repository model:

๐Ÿ”น 1. Infra Repository (Terraform)

Responsible for provisioning infrastructure:

  • Resource Group
  • Virtual Network & Subnets
  • Virtual Machines (Frontend & Backend)
  • MySQL Database
  • Outputs (VM IP, DB host)

๐Ÿ”น 2. App Repository (Ansible + Application)

Responsible for application deployment:

  • Configuring VMs
  • Installing Nginx
  • Deploying EpicBook application
  • Connecting backend with MySQL

โš™๏ธ CI/CD Architecture

The project uses two Azure DevOps pipelines:

๐Ÿ”น Infra Pipeline

Automates infrastructure provisioning using Terraform:

  • Install Terraform
  • Authenticate using Azure Service Connection (SPN)
  • Run:
  • terraform init
  • terraform plan
  • terraform apply
  • Generate outputs (VM IP, DB host)
  • Publish outputs as artifacts

๐Ÿ”น App Pipeline

Automates application deployment using Ansible:

  • Install Ansible
  • Fetch SSH keys from Secure Files
  • Update inventory dynamically using Terraform outputs
  • Deploy application on VMs
  • Configure Nginx and backend connection

โ˜๏ธ Azure DevOps Setup

To enable automation, I configured:

๐Ÿ” Service Principal (SPN)

Used for secure authentication between Azure DevOps and Azure.

๐Ÿ”— Service Connection

Created in Azure DevOps to allow Terraform to provision resources securely.

๐Ÿ”‘ Secure Files

SSH keys were stored securely in Azure DevOps:

  • Used for VM login
  • Avoided hardcoding credentials

๐Ÿ“ฆ Variable Groups

Created epicbook-secrets to store sensitive data like:

  • Database password (db_password)

๐Ÿ—๏ธ Infrastructure as Code (Terraform)

Terraform was used to automate infrastructure creation.

Key Features:

  • Declarative infrastructure definition
  • Azure VM provisioning
  • Networking setup (VNet, Subnet)
  • MySQL database setup
  • Output variables for pipeline integration

Output Example:

  • VM Public IP
  • Database Host

These outputs were passed to the next pipeline stage for application deployment.

๐Ÿค– Configuration Management (Ansible)

Ansible handled configuration and deployment:

Tasks:

  • Install Nginx on VMs
  • Deploy EpicBook application files
  • Configure backend database connection
  • Ensure application is accessible via browser

๐Ÿ”„ End-to-End CI/CD Workflow

  1. Code pushed to repository (GitHub/Azure Repo)
  2. Infra pipeline triggers automatically
  3. Terraform provisions Azure infrastructure
  4. Outputs (IP, DB host) are generated
  5. App pipeline consumes outputs
  6. Ansible configures servers
  7. Application is deployed successfully
  8. EpicBook is accessible via public IP

โš ๏ธ Challenges Faced & Fixes

During implementation, I faced several real-world DevOps issues:

โŒ Agent Connectivity Issues

  • Agent went offline or timed out
  • Fixed by restarting self-hosted agent and ensuring stable WSL connection

โŒ Service Connection Errors

  • Fixed incorrect or mismatched service connection names

โŒ Terraform Backend Issues

  • Resolved storage account mismatch and invalid backend configuration

โŒ Pipeline Blocking on sudo

  • Removed sudo usage to avoid password prompts in automation

โŒ SSH Key Configuration

  • Corrected secure file setup in Azure DevOps

๐Ÿ“š Key Learnings

This project helped me understand real-world DevOps practices:

๐Ÿ”น CI/CD Pipelines

  • Automated infrastructure + application deployment
  • Separation of concerns using multiple pipelines

๐Ÿ”น Terraform (IaC)

  • Infrastructure provisioning as code
  • State management using Azure Storage backend

๐Ÿ”น Ansible

  • Configuration management and automation
  • Remote server setup and deployment

๐Ÿ”น Azure DevOps

  • Pipeline creation and management
  • Service connections & secure authentication
  • Secure file and variable group usage

๐Ÿ”น Troubleshooting Skills

  • Debugging pipeline failures
  • Fixing authentication and backend issues
  • Handling real-time agent failures

๐ŸŽฏ Final Outcome

At the end of this project:

โœ” Azure infrastructure was fully automated โœ” Application was deployed successfully โœ” CI/CD pipeline worked end-to-end โœ” No manual intervention required

This project helped me experience how real DevOps pipelines work in production environments.

๐Ÿš€ Conclusion

Building this CI/CD pipeline gave me hands-on experience with:

  • Cloud infrastructure automation
  • Secure DevOps practices
  • Real-world deployment workflows

It strengthened my understanding of how modern applications are built, deployed, and managed in scalable cloud environments.


๋ฉ”ํƒ€๋ฐ์ดํ„ฐ
post_id
a4fef122024c
slug
building-a-real-world-ci-cd-pipeline-with-azure-devops-terraform-ansible-epicbook-project-a4fef122024c
url
https://medium.com/@jadhavaarti056/building-a-real-world-ci-cd-pipeline-with-azure-devops-terraform-ansible-epicbook-project-a4fef122024c
canonical_url
https://medium.com/@jadhavaarti056/building-a-real-world-ci-cd-pipeline-with-azure-devops-terraform-ansible-epicbook-project-a4fef122024c
author_url
https://medium.com/@jadhavaarti056
status
ok
fetched_at
2026-06-17 08:20:12