Skip to content

End-to-end demo that provisions AWS infra for Jenkins master/agent, builds a Docker image via Ansible from Jenkins, pushes to Docker Hub, and runs a simple web app.

Notifications You must be signed in to change notification settings

rozana10710/demo2-jenkins-ansbile-docker-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo: Jenkins + Ansible + Docker Web App on AWS

End-to-end demo that provisions AWS infra for Jenkins master/agent, builds a Docker image via Ansible from Jenkins, pushes to Docker Hub, and runs a simple web app. image

Architecture

  • Terraform (infra/): VPC, subnet, modular security groups, EC2 master + slave
  • Jenkins (jenkins/): Declarative pipeline to checkout and invoke Ansible
  • Ansible (ansbile/): Builds, tags, pushes image, and runs container on the agent
  • Docker (docker/): Dockerfile + static index.html

Flow

  1. Terraform creates infra; user data installs Jenkins (master) and agent deps (slave)
  2. Jenkins pipeline (on slave) checks out this repo
  3. Pipeline runs Ansible playbook to build and push image, then start container
  4. Web app becomes available on the slave’s public IP (port 80)

Prerequisites

  • AWS account + credentials for Terraform
  • Terraform >= 1.5
  • A key pair in AWS (used by instances)
  • Valid Ubuntu AMIs for master/slave
  • Docker Hub account

Quickstart

  1. Provision AWS:
cd infra
terraform init
terraform apply -auto-approve
  1. Get public IPs from AWS console or Terraform outputs
  2. Access Jenkins: http://<master-public-ip>:8080 (admin/admin123 by default; change it)
  3. In Jenkins, create a Pipeline job pointing to this repo (Jenkinsfile in jenkins/)
  4. Configure job parameters:
    • DOCKERHUB_USERNAME (string)
    • DOCKERHUB_PASSWORD (password/token)
  5. Run the pipeline
  6. Access the app: http://<slave-public-ip>

Folder Overview

  • infra/: Terraform modules, variables, and scripts
  • jenkins/: Jenkins pipeline definition
  • ansbile/: Playbook and docs for build/push/run
  • docker/: Dockerfile and static site content

Clean Up

cd infra
terraform destroy -auto-approve

Notes

  • Security groups are modular; attach only what’s needed per instance
  • The agent must allow inbound HTTP (80) to expose the demo site
  • The jenkins user must be in the docker group on the agent

About

End-to-end demo that provisions AWS infra for Jenkins master/agent, builds a Docker image via Ansible from Jenkins, pushes to Docker Hub, and runs a simple web app.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published