-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsingle-node-stack.yml
161 lines (135 loc) · 4.04 KB
/
single-node-stack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
- name: Wait for SSH Connection
hosts: all
gather_facts: no
tasks:
- name: Wait for SSH Connection on port 22
local_action: wait_for port=22 host={{ ansible_ssh_host }} search_regex=OpenSSH delay=5
- name: Setup DB Server
hosts: all
become: yes
tags: DB
tasks:
- name: Install MariaDB Server and Packages
package:
name: "{{ item }}"
state: installed
loop:
- mariadb-server
- MySQL-python
- name: Update lower case tables parameter
lineinfile:
path: /etc/my.cnf
insertafter: '^datadir'
line: 'lower_case_table_names=1'
- name: Start MariaDB Service
service:
name: mariadb
state: started
enabled: yes
- name: Copy Student.sql file
copy:
src: student.sql
dest: /tmp/student.sql
- name: Load the SQL Schema
mysql_db:
state: import
name: all
target: /tmp/student.sql
- name: Setup Application Server
hosts: all
become: yes
gather_facts: true
tags: APP
vars:
TOMCAT_URL: http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.10/bin/apache-tomcat-9.0.10.tar.gz
WAR_URL: https://github.com/cit-aliqui/APP-STACK/raw/master/student.war
JAR_URL: https://github.com/cit-aliqui/APP-STACK/raw/master/mysql-connector-java-5.1.40.jar
tasks:
- name: Install Java
package:
name: java
state: installed
- name: Get the tomcat directory
shell: echo "{{TOMCAT_URL}}" |awk -F / '{print $NF}' | sed -e 's/.tar.gz//'
register: out
- set_fact:
TOMCAT_DIR: "{{out.stdout}}"
# - name: Download tomcat
# get_url:
# url: "{{TOMCAT_URL}}"
# dest: "/opt/{{TARFILE.stdout}}"
- name: Download and extract tomcat
unarchive:
src: "{{TOMCAT_URL}}"
dest: /opt
remote_src: yes
- name: Find list of files and directories in webapps
find:
file_type: any
paths: "/opt/{{TOMCAT_DIR}}/webapps"
register: out
- name: Remove the files in webapps
file:
path: "{{item.path}}"
state: absent
loop: "{{out.files}}"
- name: Download War file
get_url:
url: "{{WAR_URL}}"
dest: "/opt/{{TOMCAT_DIR}}/webapps/student.war"
- name: Download JDBC Jar file
get_url:
url: "{{JAR_URL}}"
dest: "/opt/{{TOMCAT_DIR}}/lib/mysql-connector-java-5.1.40.jar"
- name: Update context.xml file
template:
src: context.xml.j2
dest: /opt/{{TOMCAT_DIR}}/conf/context.xml
### Explain how to access the values from another play , Also explain other options.
- name: Check tomcat is running or not
shell: ps -ef | grep java | grep -v grep
register: out
ignore_errors: true
### Explain ignore_errors.
- name: Stop if tomcat is running
when: out.rc == 0
shell: nohup /opt/{{TOMCAT_DIR}}/bin/shutdown.sh
- name: Start the tomcat
shell: nohup /opt/{{TOMCAT_DIR}}/bin/startup.sh
- name: Setup Web Server
hosts: all
become: yes
tags: WEB
tasks:
- name: Install Web Server
package:
name: httpd
state: installed
- name: Download MOD_JK library.
get_url:
url: https://github.com/cit-astrum/project-manual/raw/master/mod_jk.so
dest: /etc/httpd/modules/mod_jk.so
mode: 0755
- name: Create mod-jk configuration file
blockinfile:
path: /etc/httpd/conf.d/mod-jk.conf
create: yes
block: |
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf.d/worker.properties
JkMount /studentapi local
JkMount /studentapi/* local
- name: Create tomcat workers file
blockinfile:
path: /etc/httpd/conf.d/worker.properties
create: yes
block: |
worker.list=local
worker.local.host=localhost
worker.local.port=8009
- name: Restart web service
service:
name: httpd
state: restarted
enabled: yes