This project automates the end-to-end deployment of a web application using Jenkins, Ansible, and Docker, hosted on AWS EC2 instances for a seamless CI/CD experience.
✅ Jenkins Server:
- OS: RHEL 9
- Instance Type: t2.medium
- Allowed Port: 8080
✅ Ansible Server:
- OS: RHEL 9
- Instance Type: t2.large
- Allowed Ports: 80, 443
✅ Docker/Web Server:
- OS: RHEL 9
- Instance Type: t2.medium
- Allowed Ports: 80, 443
├── Assests # Project Images
├── Dockerfile # Docker configuration to build the application
├── build.sh # Shell script to build and push Docker image
├── docker.yaml # Ansible playbook to deploy the Docker container
└── local.repo # Custom repository configuration (if applicable)
- ✅ Successful deployment of the application on AWS EC2 using Docker and Ansible.
- ✅ Proper configuration of Jenkins for automated builds, triggers, and deployment pipelines.
- ✅ Secure and seamless file transfer and execution between Jenkins, Ansible, and Docker servers.
- ✅ Docker container accessible via the public IP or domain on port 80 using NodePort.
- ✅ Hands-on experience with managing CI/CD pipelines, Docker containerization, and Ansible playbook execution.
- ✅ Done! Your web application is now successfully deployed and running on the target server! 🎉

- Installed Jenkins and configured it on port 8080.
- Installed necessary plugins:
- Git
- Docker Pipeline
- Ansible
- SSH Publisher
- Created a webhook in the GitHub repository with Jenkins payload URL to trigger the pipeline.
- Configured Ansible and Docker.

- Established passwordless authentication using
ssh-keygenbetween:- Jenkins Server → Ansible Server
- Ansible Server → Docker/Web Server
- Installed and configured Docker.
- Ensured passwordless authentication with the Ansible Server.
- Configured Docker login to push images to Docker Hub.
When changes are pushed to the GitHub repository, the Jenkins pipeline is automatically triggered using a webhook.
Repository URL: https://github.com/kartikk26/myproject.gitFiles from the Jenkins workspace are synced to the Ansible Server using rsync for further processing.
rsync -avh /var/lib/jenkins/workspace/project-a/* root@<ANSIBLE_SERVER_IP>:/root/ansibleThe Docker image is built, tagged, and pushed to Docker Hub for version management and deployment.
cd /root/ansible
# Build Docker Image
docker build -t $JOB_NAME:$BUILD_ID .
# Tag Image
docker tag $JOB_NAME:$BUILD_ID kartikjain26/$JOB_NAME:$BUILD_ID
docker tag $JOB_NAME:$BUILD_ID kartikjain26/$JOB_NAME:latest
# Push to Docker Hub
docker push kartikjain26/$JOB_NAME:$BUILD_ID
docker push kartikjain26/$JOB_NAME:latest
# Clean up Docker Images
docker rmi -f $JOB_NAME:$BUILD_ID kartikjain26/$JOB_NAME:$BUILD_ID kartikjain26/$JOB_NAME:latestAnsible is used to deploy the Docker container to the target server.
cd /root/ansible
# Run Ansible Playbook
ansible-playbook docker.yamlpipeline {
agent any
stages {
stage('Trigger Webhook') {
steps {
echo 'Webhook triggered, starting pipeline...'
}
}
stage('Sync Files to Ansible Server') {
steps {
sh 'rsync -avz ./ ansible_user@<ansible-server-ip>:/home/ansible_user/project'
}
}
stage('Build and Push Docker Image') {
steps {
sh './build.sh'
}
}
stage('Run Ansible Playbook') {
steps {
sh 'ansible-playbook -i /etc/ansible/hosts docker.yaml'
}
}
}
}- Configured SSH key-based authentication between all servers.
- Enabled secure communication for Jenkins webhook.
- Implemented firewall rules and security groups on AWS EC2 instances.
git clone https://github.com/Kartikk-26/CI-CD-Pipeline-Project.git- Jenkins Webhook URL
- Docker Hub Credentials
- Ansible Inventory File
- Execute the pipeline and access the deployed application!
- Verify that all security groups allow traffic on required ports.
- Confirm passwordless SSH keys are properly configured between servers.
- Check Jenkins build logs for error messages if the pipeline fails.
- Ensure Docker login credentials are correctly configured.
- Public IP of Docker Server:
http://<docker-server-public-ip>

- The application becomes accessible after a successful Jenkins build and Ansible deployment.
- ✅ Successfully automated the deployment of a web application using Jenkins, Ansible, and Docker hosted on AWS EC2 instances.
- ✅ Ensured secure and seamless integration between Jenkins, Ansible, and Docker servers with passwordless authentication.
- ✅ Configured a robust CI/CD pipeline that efficiently builds, pushes, and deploys Docker containers to production.
- Stay updated on LinkedIn for more DevOps projects and insights.
- Follow along as I explore Cloud Infrastructure, Ansible Automation, and DevOps practices.
- Let's collaborate and build scalable solutions together!



