-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
153 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
tomcat_version: null | ||
tomcat_checksum: null | ||
tomcat_java_version: null | ||
tomcat_java_checksum: null | ||
|
||
tomcat_user: "{{ ansible_user }}" | ||
tomcat_user_home: "{{ ansible_user_dir }}" | ||
tomcat_src_directory: "{{ tomcat_user_home }}/src" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Reload Apache Tomcat user service | ||
listen: tomcat changed | ||
ansible.builtin.systemd: | ||
name: tomcat | ||
daemon_reload: true | ||
enabled: true | ||
scope: user | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
dependencies: | ||
- role: java | ||
vars: | ||
java_version: "{{ tomcat_java_version }}" | ||
java_checksum: "{{ tomcat_java_checksum }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
- name: Ensure required directories are present. | ||
ansible.builtin.file: | ||
dest: "{{ item.dest }}" | ||
state: directory | ||
mode: "0700" | ||
loop: | ||
- { dest: "{{ tomcat_src_directory }}/download" } | ||
- { dest: "{{ tomcat_user_home }}/.config/systemd/user" } | ||
- { dest: "{{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}" } | ||
|
||
- name: Ensure binary archive is present. | ||
ansible.builtin.get_url: | ||
url: https://dlcdn.apache.org/tomcat/tomcat-{{ tomcat_version_major }}/v{{ tomcat_version }}/bin/apache-tomcat-{{ tomcat_version }}.tar.gz | ||
dest: "{{ tomcat_src_directory }}/download/apache-tomcat-{{ tomcat_version }}.tar.gz" | ||
checksum: "{{ tomcat_checksum }}" | ||
mode: "0600" | ||
|
||
- name: Ensure binary archive is extracted. | ||
ansible.builtin.unarchive: | ||
src: "{{ tomcat_src_directory }}/download/apache-tomcat-{{ tomcat_version }}.tar.gz" | ||
dest: "{{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}" | ||
creates: "{{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/RELEASE-NOTES" | ||
remote_src: true | ||
extra_opts: | ||
- --strip-components=1 | ||
- --exclude=bin/*.bat | ||
- --exclude=conf/server.xml | ||
- --exclude=conf/tomcat-users.* | ||
- --exclude=webapps/* | ||
mode: u=rwX,g=,o= | ||
|
||
- name: Ensure Tomcat server configuration is present. | ||
ansible.builtin.template: | ||
src: server.xml.j2 | ||
dest: "{{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/conf/server.xml" | ||
mode: "0600" | ||
notify: tomcat changed | ||
|
||
- name: Ensure systemd user service file. | ||
ansible.builtin.template: | ||
src: tomcat.service.j2 | ||
dest: "{{ tomcat_user_home }}/.config/systemd/user/tomcat.service" | ||
mode: "0600" | ||
notify: tomcat changed | ||
|
||
- name: Check if user is lingering. | ||
ansible.builtin.stat: | ||
path: /var/lib/systemd/linger/{{ tomcat_user }} | ||
register: tomcat_user_lingering | ||
|
||
- name: Enable user lingering. | ||
ansible.builtin.command: loginctl enable-linger {{ tomcat_user }} | ||
when: not tomcat_user_lingering.stat.exists | ||
changed_when: true | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<Server port="-1" shutdown="SHUTDOWN"> | ||
<Listener className="org.apache.catalina.startup.VersionLoggerListener" /> | ||
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> | ||
<!-- Prevent memory leaks due to use of particular java/javax APIs--> | ||
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> | ||
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> | ||
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> | ||
|
||
<GlobalNamingResources> | ||
</GlobalNamingResources> | ||
|
||
<Service name="Catalina"> | ||
<Connector port="8081" protocol="HTTP/1.1" | ||
connectionTimeout="20000" | ||
maxParameterCount="1000" | ||
/> | ||
|
||
<Engine name="Catalina" defaultHost="localhost"> | ||
<Host name="localhost" appBase="webapps" | ||
unpackWARs="true" autoDeploy="true"> | ||
|
||
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" | ||
prefix="localhost_access_log" suffix=".txt" | ||
pattern="%h %l %u %t "%r" %s %b" /> | ||
|
||
</Host> | ||
</Engine> | ||
</Service> | ||
</Server> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Unit] | ||
Description=Apache Tomcat {{ tomcat_version }} | ||
After=syslog.target network-online.target remote-fs.target nss-lookup.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
Type=forking | ||
UMask=0077 | ||
PIDFile={{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/tomcat.pid | ||
Environment="CATALINA_PID={{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/tomcat.pid" | ||
Environment="CATALINA_HOME={{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}" | ||
Environment="CATALINA_OPTS=-server -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF-8" | ||
Environment="JRE_HOME={{ java_user_home }}/usr/lib/jvm/{{ tomcat_java_version }}" | ||
ExecStart={{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/bin/startup.sh | ||
ExecStop={{ tomcat_user_home }}/opt/tomcat/{{ tomcat_version }}/bin/shutdown.sh 30 -force | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
hosts: webservers | ||
|
||
roles: | ||
- role: java | ||
- role: tomcat | ||
- role: nginx | ||
- role: logrotate | ||
- role: iptables |