diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d81a691
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,8 @@
+# Pull base image
+FROM tomcat:8-jre8
+
+# Maintainer
+MAINTAINER "rahul"
+
+# copy war file on to container
+COPY target/*.war /usr/local/tomcat/webapps
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..565b135
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,59 @@
+pipeline {
+ agent any
+ parameters {
+ choice choices: ['develop', 'release', 'master'], description: 'Please provide the branch name so that we can deploy', name: 'branch'
+ }
+
+ triggers {
+ pollSCM 'H/2 * * * * '
+ }
+ tools {
+ maven 'maven'
+ }
+ environment {
+ project_type = 'java'
+ DEPLOY_TO = 'production'
+ }
+ stages {
+ stage('git fetch') {
+ steps {
+ git branch: "${params.branch}", credentialsId: '4991f864-6845-456a-90df-f0f62edcdc79', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+
+ stage('Build the code') {
+ when{
+ environment name: 'project_type', value: 'java'
+ }
+ steps {
+ sh 'mvn -Dmaven.test.failure.ignore=true clean package'
+ echo "deploying to ${DEPLOY_TO} Env "
+ deploy adapters: [tomcat8(credentialsId: 'tomcat-cred', path: '', url: 'http://172.31.32.223:8080')], contextPath: 'login-release-branch', onFailure: false, war: '**/*.war'
+ }
+ }
+
+ }
+ post {
+ always {
+ echo "You can always see me"
+ }
+ success {
+
+
+
+ echo "I am running because the job ran successfully"
+ //sh '/usr/local/bin/aws s3 cp /jenkins-home/workspace/stage-tavisca/target/LoginRegisterApp.war s3://9am-weekend-jul/$JOB_NAME/${BUILD_NUMBER}/'
+
+
+
+
+ }
+ unstable {
+ echo "Gear up ! The build is unstable. Try fix it"
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+
+}
diff --git a/Jenkinsfile-ansible-project b/Jenkinsfile-ansible-project
new file mode 100644
index 0000000..9c9ae83
--- /dev/null
+++ b/Jenkinsfile-ansible-project
@@ -0,0 +1,32 @@
+pipeline {
+ agent any
+
+ tools {
+ maven 'maven'
+ }
+
+
+ stages {
+
+ stage('Fetch the new code') {
+ steps {
+ git branch: 'develop', credentialsId: 'github-repo', url: 'https://github.com/devopscloudsre/java-db-Login.git'
+ }
+ }
+
+ stage('Build') {
+ steps {
+
+ sh 'mvn clean package'
+ }
+
+ post {
+ // If Maven was able to run the tests, even if some of the test
+ // failed, record the test results and archive the jar file.
+ success {
+ s3Upload consoleLogLevel: 'INFO', dontSetBuildResultOnFailure: false, dontWaitForConcurrentBuildCompletion: false, entries: [[bucket: 'lwplabs', excludedFile: 'target', flatten: true, gzipFiles: false, keepForever: false, managedArtifacts: false, noUploadOnFailure: true, selectedRegion: 'us-east-1', showDirectlyInBrowser: false, sourceFile: '**/*.war', storageClass: 'STANDARD', uploadFromSlave: false, useServerSideEncryption: false]], pluginFailureResultConstraint: 'FAILURE', profileName: 's3profile', userMetadata: []
+ }
+ }
+ }
+ }
+}
diff --git a/README.md b/README.md
index ba52519..ef220b6 100644
--- a/README.md
+++ b/README.md
@@ -14,3 +14,9 @@ mysql> use tempdb;
mysql> create table user(name varchar(100),password varchar(100), address varchar(1000), age int, profession varchar(100));
mysql> select * from User;
+
+#Update files with the new database details
+
+## - /root/java-db-Login/src/main/webapp/WEB-INF/web.xml
+## - /root/java-db-Login/src/main/java/com/example/application.properties
+## - /root/java-db-Login/src/main/java/com/example/DbUtil.java
diff --git a/ansible-playbook.yml b/ansible-playbook.yml
new file mode 100644
index 0000000..81d5eb3
--- /dev/null
+++ b/ansible-playbook.yml
@@ -0,0 +1,121 @@
+---
+- name: Play1 for copying files
+ hosts: dockerMaster
+ become: yes
+ tasks:
+ - name: Create a directory if it does not exist
+ file:
+ path: /tmp/{{ job_name }}
+ state: directory
+ mode: '0755'
+ owner: ansadmin
+ group: root
+ tags:
+ - create-dir
+
+ - name: Copy the war file, dockerfile & lwplabs-com.yml to docker master server
+ copy:
+ src: "{{ ANSIBLE_WORKSPACE }}/"
+ dest: /tmp/{{ job_name }}
+ owner: ansadmin
+ group: root
+ mode: '0777'
+ tags:
+ - copy_code
+
+- name: "Play 2- python installation"
+ hosts: dockerMaster
+ become: yes
+ tasks:
+ - name: Install Python 3.6
+ yum:
+ name: python36
+ state: present
+ register: out1
+ tags:
+ - python-install
+ - debug:
+ var: out1
+
+ - name: alternatives
+ alternatives:
+ name: python
+ link: /usr/bin/python3.6
+ path: /usr/bin/python3
+ register: out2
+ tags:
+ - python-alternatives
+ - debug:
+ var: out2
+
+- name: "Play 3 Install Python packages and docker image push"
+ hosts: dockerMaster
+ become: yes
+ vars:
+ ansible_python_interpreter: /usr/bin/python3
+ tasks:
+ - name: Install boto3 and botocore with pip3 module
+ pip:
+ name:
+ - boto
+ - boto3
+ - botocore
+ - docker
+ #- docker-py
+ - jsondiff
+ - pyyaml
+ executable: pip3.6
+ register: out3
+ tags: docker-lib-install
+ - debug:
+ var: out3
+
+ - name: "Delete the docker image"
+ docker_image:
+ state: absent
+ force: yes
+ name: 127.0.0.1:5000/lwplabslogin
+ tag: latest
+ register: out4
+ tags: docker-image-deletion
+ - debug:
+ var: out4
+
+ - name: "Build an image and push it to a private repo"
+ docker_image:
+ build:
+ path: /tmp/{{ job_name }}
+ name: 127.0.0.1:5000/lwplabslogin
+ tag: "latest"
+ push: yes
+ nocache: yes
+ force: yes
+ register: out5
+ tags: docker-image-build
+ - debug:
+ var: out5
+
+- name: "Play 3 docker stack deploy"
+ hosts: dockerMaster
+ become: yes
+ tasks:
+ - name: Remove stack
+ docker_stack:
+ name: "{{ job_name }}"
+ state: absent
+ tags: docker-stack-remove
+
+ - name: sleep for 10 sec
+ shell: sleep 10
+
+ - name: Deploy stack from a compose file
+ docker_stack:
+ state: present
+ name: "{{ job_name }}"
+ compose:
+ - /tmp/{{ job_name }}/docker-stack.yml
+ register: out6
+ tags: docker-stack-deploy
+ - debug:
+ var: out6
+
diff --git a/dev.ini b/dev.ini
new file mode 100644
index 0000000..dd09056
--- /dev/null
+++ b/dev.ini
@@ -0,0 +1,6 @@
+[dockerMaster]
+ip-172-31-29-23 ansible_user=ansadmin
+
+[webservers]
+172.31.83.173
+172.31.86.28
\ No newline at end of file
diff --git a/docker-stack.yml b/docker-stack.yml
new file mode 100644
index 0000000..613d096
--- /dev/null
+++ b/docker-stack.yml
@@ -0,0 +1,24 @@
+version: '3.9'
+
+services:
+ tomcat:
+ image: 127.0.0.1:5000/lwplabslogin:latest
+ #build: .
+ deploy:
+ replicas: 2
+ placement:
+ max_replicas_per_node: 1
+ restart_policy:
+ condition: on-failure
+ delay: 5s
+ max_attempts: 3
+ window: 120s
+ resources:
+ limits:
+ cpus: '0.50'
+ memory: 200M
+ reservations:
+ cpus: '0.25'
+ memory: 100M
+ ports:
+ - "8080:8080"
diff --git a/jenkinsfile-majorproject7 b/jenkinsfile-majorproject7
new file mode 100644
index 0000000..a32937e
--- /dev/null
+++ b/jenkinsfile-majorproject7
@@ -0,0 +1,28 @@
+pipeline {
+ agent any
+
+ tools {
+ maven 'maven'
+ }
+
+ stages {
+ stage('Build') {
+ steps {
+ // Get some code from a GitHub repository
+ git branch: 'develop', credentialsId: 'ansadmin-key', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+
+ // Run Maven on a Unix agent.
+ sh "mvn -Dmaven.test.failure.ignore=true clean package"
+
+ }
+
+ post {
+ // If Maven was able to run the tests, even if some of the test
+ // failed, record the test results and archive the jar file.
+ success {
+ ansiblePlaybook credentialsId: 'ansadmin-key', disableHostKeyChecking: true, extras: '-e job_name=$JOB_NAME -e ANSIBLE_WORKSPACE=$WORKSPACE', forks: 5, installation: 'ansible', inventory: 'dev.ini', playbook: 'ansible-playbook.yml'
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/example/DbUtil.java b/src/main/java/com/example/DbUtil.java
index 4fda626..4d943ba 100644
--- a/src/main/java/com/example/DbUtil.java
+++ b/src/main/java/com/example/DbUtil.java
@@ -9,9 +9,9 @@
public class DbUtil {
static Connection con=null;
static String driver = "com.mysql.cj.jdbc.Driver";
- static String url = "jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/flipkart";
+ static String url = "jdbc:mysql://lwplabs.cdo5uynfnrno.us-east-1.rds.amazonaws.com:3306/homeloan";
static String username = "admin";
- static String password = "test123test";
+ static String password = "admin123";
static {
try {
diff --git a/src/main/java/com/example/application.properties b/src/main/java/com/example/application.properties
index fd3101a..f363a03 100644
--- a/src/main/java/com/example/application.properties
+++ b/src/main/java/com/example/application.properties
@@ -1,4 +1,4 @@
database.driver=com.mysql.cj.jdbc.Driver
-database.url=jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/flipkart
+database.url=jdbc:mysql://lwplabs.cdo5uynfnrno.us-east-1.rds.amazonaws.com:3306/homeloan
database.username=admin
-database.password=test123test
+database.password=admin123
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 249c9f6..0de7b83 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -10,15 +10,15 @@
dbPassword
- welcome123
+ admin123
dbURL
- jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/
+ jdbc:mysql://lwplabs.cdo5uynfnrno.us-east-1.rds.amazonaws.com:3306/
dbName
- flipkart
+ homeloan
LoginServlet
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 17ed961..998be19 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -1,7 +1,7 @@
- Welcome Page
+ Devops Major Foundation Project 1
Login
Register
-
\ No newline at end of file
+