Skip to content

Commit 6ef8bf5

Browse files
authored
Add files via upload
1 parent 9529862 commit 6ef8bf5

File tree

100 files changed

+11291
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+11291
-1
lines changed

README.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# devops_multitier_webapplication
1+
# THIS PROJECT BELONGS TO UDEMY AND I'VE CLONED IT FOR EDUCATIONAL PURPOSES
2+
# Prerequisites
3+
#
4+
- JDK 11
5+
- Maven 3 or later
6+
- MySQL 5.6 or later
7+
8+
# Technologies
9+
- Spring MVC
10+
- Spring Security
11+
- Spring Data JPA
12+
- Maven
13+
- JSP
14+
- MySQL
15+
# Database
16+
Here,we used Mysql DB
17+
MSQL DB Installation Steps for Linux ubuntu 14.04:
18+
- $ sudo apt-get update
19+
- $ sudo apt-get install mysql-server
20+
21+
Then look for the file :
22+
- /src/main/resources/accountsdb
23+
- accountsdb.sql file is a mysql dump file.we have to import this dump to mysql db server
24+
- > mysql -u <user_name> -p accounts < accountsdb.sql
25+
26+

ansible/ansible.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
host_key_checking = False
3+
timeout = 30

ansible/site.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- import_playbook: tomcat_setup.yml
3+
- import_playbook: vpro-app-setup.yml
4+
5+
###

ansible/templates/application.j2

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#JDBC Configutation for Database Connection
2+
jdbc.driverClassName=com.mysql.jdbc.Driver
3+
jdbc.url=jdbc:mysql://dbhost:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
4+
jdbc.username=db_user
5+
jdbc.password=db_password
6+
7+
#Memcached Configuration For Active and StandBy Host
8+
#For Active Host
9+
memcached.active.host=127.0.0.1
10+
memcached.active.port=11211
11+
#For StandBy Host
12+
memcached.standBy.host=127.0.0.2
13+
memcached.standBy.port=11211
14+
15+
#RabbitMq Configuration
16+
rabbitmq.address=18.220.62.126
17+
rabbitmq.port=5672
18+
rabbitmq.username=test
19+
rabbitmq.password=test
20+
21+
#Elasticesearch Configuration
22+
elasticsearch.host =192.168.1.85
23+
elasticsearch.port =9300
24+
elasticsearch.cluster=vprofile
25+
elasticsearch.node=vprofilenode

ansible/templates/epel6-svcfile.j2

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
### BEGIN INIT INFO
4+
# Provides: tomcat7
5+
# Required-Start: $network
6+
# Required-Stop: $network
7+
# Default-Start: 2 3 4 5
8+
# Default-Stop: 0 1 6
9+
# Short-Description: Start/Stop Tomcat server
10+
### END INIT INFO
11+
12+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
13+
14+
start() {
15+
sh /usr/local/tomcat8/bin/startup.sh
16+
}
17+
18+
stop() {
19+
sh /usr/local/tomcat8/bin/shutdown.sh
20+
}
21+
22+
status() {
23+
pid=$(ps -fe | grep '/usr/local/tomcat8' | grep -v grep | tr -s " " | cut -d" " -f2)
24+
if [ -n "$pid" ]; then
25+
echo -e "\e[00;32mTomcat is running with pid: $pid\e[00m"
26+
else
27+
echo -e "\e[00;31mTomcat is not running\e[00m"
28+
fi
29+
}
30+
31+
case $1 in
32+
start|stop|status) $1;;
33+
restart) stop; start;;
34+
*) echo "Run as $0 "; exit 1;;
35+
esac
36+
exit 0
37+
38+

ansible/templates/epel7-svcfile.j2

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Tomcat
3+
After=network.target
4+
5+
[Service]
6+
User=tomcat
7+
WorkingDirectory=/usr/local/tomcat8
8+
Environment=JRE_HOME=/usr/lib/jvm/jre
9+
Environment=JAVA_HOME=/usr/lib/jvm/jre
10+
Environment=CATALINA_HOME=/usr/local/tomcat8
11+
Environment=CATALINE_BASE=/usr/local/tomcat8
12+
ExecStart=/usr/local/tomcat8/bin/catalina.sh run
13+
ExecStop=/usr/local/tomcat8/bin/shutdown.sh
14+
SyslogIdentifier=tomcat-%i
15+
16+
[Install]
17+
WantedBy=multi-user.target
18+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
### BEGIN INIT INFO
4+
# Provides: tomcat7
5+
# Required-Start: $network
6+
# Required-Stop: $network
7+
# Default-Start: 2 3 4 5
8+
# Default-Stop: 0 1 6
9+
# Short-Description: Start/Stop Tomcat server
10+
### END INIT INFO
11+
12+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
13+
14+
start() {
15+
sh /usr/local/tomcat8/bin/startup.sh
16+
}
17+
18+
stop() {
19+
sh /usr/local/tomcat8/bin/shutdown.sh
20+
}
21+
22+
status() {
23+
pid=$(ps -fe | grep '/usr/local/tomcat8' | grep -v grep | tr -s " " | cut -d" " -f2)
24+
if [ -n "$pid" ]; then
25+
echo -e "\e[00;32mTomcat is running with pid: $pid\e[00m"
26+
else
27+
echo -e "\e[00;31mTomcat is not running\e[00m"
28+
fi
29+
}
30+
31+
case $1 in
32+
start|stop|status) $1;;
33+
restart) stop; start;;
34+
*) echo "Run as $0 "; exit 1;;
35+
esac
36+
exit 0
37+
38+

ansible/templates/ubuntu16-svcfile.j2

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Tomcat
3+
After=network.target
4+
5+
[Service]
6+
User=tomcat
7+
WorkingDirectory=/usr/local/tomcat8
8+
Environment=JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
9+
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
10+
Environment=CATALINA_HOME=/usr/local/tomcat8
11+
Environment=CATALINE_BASE=/usr/local/tomcat8
12+
ExecStart=/usr/local/tomcat8/bin/catalina.sh run
13+
ExecStop=/usr/local/tomcat8/bin/shutdown.sh
14+
SyslogIdentifier=tomcat-%i
15+
16+
[Install]
17+
WantedBy=multi-user.target
18+

ansible/tomcat_setup.yml

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
- name: Common tool setup on all the servers
2+
hosts: appsrvgrp
3+
become: yes
4+
vars:
5+
tom_url: https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.tar.gz
6+
7+
tasks:
8+
- name: Install JDK on Centos 6/7
9+
yum:
10+
name: java-1.8.0-openjdk.x86_64
11+
state: present
12+
when: ansible_distribution == 'CentOS'
13+
14+
- name: Install JDK on Ubuntu 14/15/16/18
15+
apt:
16+
name: openjdk-8-jdk
17+
state: present
18+
update_cache: yes
19+
when: ansible_distribution == 'Ubuntu'
20+
21+
- name: Download Tomcat Tar Ball/Binaries
22+
get_url:
23+
url: "{{tom_url}}"
24+
dest: /tmp/tomcat-8.tar.gz
25+
26+
- name: Add tomcat group
27+
group:
28+
name: tomcat
29+
state: present
30+
31+
- name: Add tomcat user
32+
user:
33+
name: tomcat
34+
group: tomcat
35+
shell: /bin/nologin
36+
home: /usr/local/tomcat8
37+
38+
- file:
39+
path: /tmp/tomcat8
40+
state: directory
41+
42+
- name: Extract tomcat
43+
unarchive:
44+
src: /tmp/tomcat-8.tar.gz
45+
dest: /tmp/tomcat8/
46+
remote_src: yes
47+
list_files: yes
48+
register: unarchive_info
49+
50+
- debug:
51+
msg: "{{unarchive_info.files[0].split('/')[0]}}"
52+
53+
- name: Synchronize /tmp/tomcat8/tomcat_cont /usr/local/tomcat8.
54+
synchronize:
55+
src: "/tmp/tomcat8/{{unarchive_info.files[0].split('/')[0]}}/"
56+
dest: /usr/local/tomcat8/
57+
delegate_to: "{{ inventory_hostname }}"
58+
59+
- name: Change ownership of /usr/local/tomcat8
60+
file:
61+
path: /usr/local/tomcat8
62+
owner: tomcat
63+
group: tomcat
64+
recurse: yes
65+
66+
- name: Setup tomcat SVC file on Centos 7
67+
template:
68+
src: templates/epel7-svcfile.j2
69+
dest: /etc/systemd/system/tomcat.service
70+
mode: "a+x"
71+
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7'
72+
73+
- name: Setup tomcat SVC file on Centos 6
74+
template:
75+
src: templates/epel6-svcfile.j2
76+
dest: /etc/init.d/tomcat
77+
mode: "a+x"
78+
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '6'
79+
80+
- name: Setup tomcat SVC file on ubuntu 14/15
81+
template:
82+
src: templates/ubuntu14_15-svcfile.j2
83+
dest: /etc/init.d/tomcat
84+
mode: "a+x"
85+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version < '16'
86+
87+
- name: Setup tomcat SVC file on ubuntu 16 and 18
88+
template:
89+
src: templates/ubuntu16-svcfile.j2
90+
dest: /etc/systemd/system/tomcat.service
91+
mode: "a+x"
92+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '16'
93+
94+
- name: Reload tomcat svc config in ubuntu 14/15
95+
command: update-rc.d tomcat defaults
96+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version < '16'
97+
98+
- name: Reload tomcat svc config in Centos 6
99+
command: chkconfig --add tomcat
100+
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '6'
101+
102+
- name: just force systemd to reread configs (2.4 and above)
103+
systemd:
104+
daemon_reload: yes
105+
when: ansible_distribution_major_version > '6' or ansible_distribution_major_version > '15'
106+
107+
- name: Start & Enable TOmcat 8
108+
service:
109+
name: tomcat
110+
state: started
111+
enabled: yes
112+
113+

0 commit comments

Comments
 (0)