-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathmain.yml
191 lines (172 loc) · 5.14 KB
/
main.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# set up tomcat consistently whenever needed. Used as:
# - include: ../common/tasks/tomcat.yml
# "tomcat" variable controls version (@see common/vars)
- include: ../../common/tasks/setfacts.yml
tags:
- packages
- tomcat
- name: Install universe repository for tomcat7 install
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu xenial universe
state: present
when: ansible_os_family == "Debian" and ansible_distribution_version == "18.04" and tomcat == "tomcat7"
tags:
- packages
- tomcat
- name: install libtcnative-1 (RedHat)
yum: pkg={{libtcnative}} state=present
when: ansible_os_family == "RedHat" and tomcat_apr | bool == True
tags:
- packages
- tomcat
- name: install tomcat (RedHat)
yum: name={{tomcat}} state=present
notify:
- restart tomcat
when: ansible_os_family == "RedHat"
tags:
- packages
- tomcat
- name: install libtcnative-1 (Debian)
apt: pkg={{libtcnative}} state=latest update_cache=yes
when: ansible_os_family == "Debian" and tomcat_apr | bool == True
tags:
- packages
- tomcat
- name: install tomcat (Debian)
apt: pkg={{tomcat}} state=latest update_cache=yes
when: ansible_os_family == "Debian"
register: tomcat_installed
tags:
- packages
- tomcat
- name: Create systemd service override directory for tomcat9
file:
path: /etc/systemd/system/tomcat9.service.d
state: directory
owner: root
group: root
mode: 0755
when:
- tomcat == "tomcat9"
register: tomcat_systemd_override_directory_created
tags:
- tomcat
notify:
- restart tomcat
- name: Override systemd for tomcat9
template:
src: systemd-service-override.conf.j2
dest: /etc/systemd/system/tomcat9.service.d/override.conf
owner: root
group: root
mode: 0644
when:
- tomcat == "tomcat9"
register: tomcat_systemd_override_installed
tags:
- tomcat
notify:
- restart tomcat
- name: force systemd to reread configs
systemd:
daemon_reload: yes
when:
- tomcat == "tomcat9"
- tomcat_systemd_override_installed.changed | bool == True or tomcat_systemd_override_directory_created.changed | bool == True
tags:
- tomcat
notify:
- restart tomcat
- name: enable the HTTP 1.1 connector (Tomcat-7/8)
tomcat_connector: name="HTTP/1.1" bind_addr="{{ tomcat_bind_addr }}" port="{{ tomcat_http_port }}"
when:
- tomcat_http | bool == True
- tomcat == "tomcat7" or tomcat == "tomcat8"
tags:
- tomcat
notify:
- restart tomcat
- name: enable the HTTP 1.1 connector (Tomcat-9)
tomcat9_connector: name="HTTP/1.1" bind_addr="{{ tomcat_bind_addr }}" port="{{ tomcat_http_port }}"
when:
- tomcat_http | bool == True
- tomcat == "tomcat9"
tags:
- tomcat
notify:
- restart tomcat
- name: enable the AJP 1.3 connector (Tomcat-7/8)
tomcat_connector: name="AJP/1.3" bind_addr="{{ tomcat_bind_addr }}" port="{{ tomcat_ajp_port }}"
when:
- tomcat_ajp | bool == True
- tomcat == "tomcat7" or tomcat == "tomcat8"
tags:
- tomcat
notify:
- restart tomcat
- name: enable the AJP 1.3 connector (Tomcat-9)
tomcat9_connector: name="AJP/1.3" bind_addr="{{ tomcat_bind_addr }}" port="{{ tomcat_ajp_port }}"
when:
- tomcat_ajp | bool == True
- tomcat == "tomcat9"
tags:
- tomcat
notify:
- restart tomcat
# replace the commented out java_opts that ships with the CentOS install which is:
# JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
- name: configure tomcat memory (RedHat)
blockinfile:
path={{tomcat_conf}}
marker="# {mark} Configure Tomcat Memory (Ansible managed)"
block='JAVA_OPTS="${JAVA_OPTS} {{tomcat_java_opts}} -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"'
backup=yes
notify:
- restart tomcat
when: ansible_os_family == "RedHat"
tags:
- tomcat
- name: configure tomcat memory (Debian)
blockinfile:
path={{tomcat_conf}}
marker="# {mark} Configure Tomcat Memory (Ansible managed)"
block='JAVA_OPTS="${JAVA_OPTS} {{tomcat_java_opts}}"'
backup=yes
notify:
- restart tomcat
when: ansible_os_family == "Debian"
tags:
- tomcat
- name: Set JAVA_HOME (Debian)
lineinfile: "
dest={{tomcat_conf}}
regexp=^JAVA_HOME
line='JAVA_HOME={{ java_home }}'"
notify:
- restart tomcat
when: ansible_os_family == "Debian"
tags:
- tomcat
- name: ensure tomcat temp directory exists
file: path={{ tomcat_temp_directory | default("/data/tmp/tomcat-tmp") }} state=directory owner={{ tomcat_user }} group={{ tomcat_user }}
notify:
- restart tomcat
when: ansible_os_family == "Debian"
tags:
- tomcat
- name: configure tomcat temp directory (Debian)
blockinfile:
path={{tomcat_conf}}
marker="# {mark} Configure Tomcat Temp Directory, which will be created and destroyed every time tomcat starts and stops (Ansible managed)"
block=JVM_TMP="{{ tomcat_temp_directory | default('/data/tmp/tomcat-tmp')}}"
backup=yes
notify:
- restart tomcat
when: ansible_os_family == "Debian"
tags:
- tomcat
- name: prepare user prefs directory
file: path=/usr/share/{{ tomcat }}/.java state=directory owner={{ tomcat_user }} group={{ tomcat_user }}
tags:
- tomcat