项目作者: vdharmaraj
项目描述 :
CI/CD Deployment Using Ansible CM Tool
高级语言: Java
项目地址: git://github.com/vdharmaraj/PGDO_CM_Project_1.git
PGDO_CM_Project_1
CI/CD Deployment Using Ansible CM Tool
Objective:
Solution build should demonstrate below capabilities:
- Configure Jenkins server as Ansible provisioning machine
- Install Ansible plugins in Jenkins CI server
- Prepare Ansible playbook to run Maven build on Jenkins CI server
- Prepare Ansible playbook to execute deployment steps on the remote web container with restart of the web container post deployment
Project goal is to Automate Ansible integration with Jenkins CI server so that we can run and execute playbooks to deploy custom WAR files to a web container and then perform restart for the web container.
Tools required:
Ansible, GitHub, Git, Linux (Ubuntu), Jenkins
Important Artifacts in the project
1) maven playbook file (/maven.yaml) is used to install maven and do maven build in the CI server
2) Main playbook (/main.yml) , tomcat ansible-role playbook (/roles/tomcat/tasks/main.yml) and inventory file (/inventories/dev/hosts) where managed node IPs are maintained, these are important files to deploy the java application in managed nodes
3) Jenkinsfile (/Jenkinsfile) is the jenkins pipeline script written to exeute the CI/CD in stages to do the code build and deploy the changes to the managed nodes
4) Java Web App (/src/main/webapp/) contains a simple login page webapp created with Servlets
5) POM file (/pom.xml) to do build and package the application into a WAR file
6) Shell Script (/roles/tomcat/files/tomcat-initscript.sh) to start and stop tomcat server
System Requirements
1 Master Node - With Ubantu OS and 4 GB RAM minimum - Installed with Python3, Java8, Ansible, Jenkins and Git
1..N Managed Nodes - with Ubantu OS and 4 GB RAM minimum - Python 3 installed
Changes to be done while reusing the project
1) change the hosts in the inventory file (inventories/dev/hosts)
2) In the Jenkins pipeline script file (/Jenkinsfile) , checkout stage related git clone url and branch has to be changed according to your github links.This stage in Jenkinsfile is just used for displaying the Git repository fetch.
Steps to Execute the Project:
Step 1:
Master Node should have a user called ‘jenkins’ after the Jenkisn Installation, this user should be configured to connect to localhost with SSH.
Step 2:
In every managed node, ‘jenkins’ user has to be created with root user privilege and a SSH connectivity has to be establised from master node jenkins user to managed node jenkins user
Step 3:
Install Git and Ansible addin in the Jenkins server
Step 4:
Create a Jenkins pipeline Job which is using the Jenkinsfile from this project repository, set the job trigger as Poll SCM pointing to this gihub repository
Step 5:
Test the sample login web app java application runing in the managed nodes by accessing the url
http://~Managed_node_ip~:8080/LoginWebApp-1/
Project Documentation
Click
here to access the project documentation I have created to submit for my DevOps PG certification program requirements