An automated DevOps pipeline that integrates Jenkins with Ansible to provision and configure AWS EC2 instances through secure, multi-stage remote execution.
This project demonstrates an end-to-end deployment workflow:
- Pulls infrastructure/configuration code from GitLab
- Prepares a remote Ansible control node
- Executes Ansible playbooks against AWS EC2 instances
- Handles secure credential management across multiple hops
- Jenkins pulls latest configuration from GitLab
- Synchronizes project files to Ansible control node
- Installs dependencies (Ansible, boto3) via Bash
- Ensures environment is ready for execution
- Injects SSH keys using Jenkins Credentials
- Applies strict permissions (
chmod 400) - Transfers AWS
.pemkey securely at runtime
- Runs playbooks from control node
- Configures AWS EC2 instances
- Ensures consistent infrastructure state
- Jenkins (CI/CD, Declarative Pipelines): I used Jenkins because it was the default tool at the workplace. I would've used GitHub Actions or GitLab CI.
- Ansible (Configuration Management)
- AWS EC2 (Cloud Compute)
- GitLab (Version Control)
- Bash (Automation Scripting)
- SSH Agent + Jenkins Credentials (Security)
- Multi-hop SSH authentication (Jenkins → Ansible → EC2)
- Pipeline as Code using Jenkinsfile (Groovy + Declarative syntax)
- Dynamic inventory handling for AWS EC2
- Linux automation for dependency installation
- Secure credential management and secret handling
- JSch authentication errors → Switched to native OpenSSH with
sshagent - Credential ID mismatches → Aligned Jenkins credentials with pipeline variables
- Interactive shell blocking (apt) → Used
DEBIAN_FRONTEND=noninteractive - Missing SSH key at runtime → Injected
.pemviawithCredentials
- ✔ Fully automated, one-click deployment pipeline
- ✔ Secure multi-stage credential handling
- ✔ Consistent EC2 configuration via Ansible
- ✔ Repeatable infrastructure provisioning workflow
This project demonstrates how to integrate CI/CD pipelines with configuration management tools to achieve secure, automated infrastructure deployment. It highlights real-world challenges in authentication, remote execution, and environment setup—along with practical solutions for building reliable DevOps systems.
Step 3: Jenkins Configuration Pipeline

Step 4: Jenkins Adjust Credentials




