-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
installTomcat9.yaml
72 lines (72 loc) · 2.13 KB
/
installTomcat9.yaml
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
- hosts: all
become: true
tasks:
- name: Install Java
yum:
name: java-1.8.0-amazon-corretto-devel
state: present
- name: add tomcatuser
user:
name: tomcat
shell: /sbin/nologin
- name: Tomcat-9 Installation
get_url:
url: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.85/bin/apache-tomcat-9.0.85.tar.gz
dest: /tmp/
- name: copy
copy:
src: /tmp/apache-tomcat-9.0.85.tar.gz
dest: /usr/local/
remote_src: yes
- name: Unpacking the archive
unarchive:
src: /usr/local/apache-tomcat-9.0.85.tar.gz
dest: /usr/local
remote_src: yes
- name: Change file ownership, group and permissions
file:
path: /usr/local/apache-tomcat-9.0.85
owner: tomcat
group: tomcat
recurse: yes
state: directory
- name: make tomcat symbolic link
file:
src: /usr/local/apache-tomcat-9.0.85
dest: /usr/local/tomcat9
owner: tomcat
group: tomcat
state: link
- name: make tomcat.service
file:
path: /etc/systemd/system/tomcat.service
state: touch
- name: edit tomcat.service
blockinfile:
dest: /etc/systemd/system/tomcat.service
insertafter:
block: |
[Unit]
Description = Apache Tomcat 9
After = syslog.target network.target
[Service]
User = tomcat
Group = tomcat
Type = oneshot
PIDFile =/usr/local/apache-tomcat-9.0.80/tomcat.pid
RemainAfterExit = yes
ExecStart =/usr/local/apache-tomcat-9.0.80/bin/startup.sh
ExecStop =/usr/local/apache-tomcat-9.0.80/bin/shutdown.sh
ExecReStart =/usr/local/apache-tomcat-9.0.80/bin/shutdown.sh;/usr/local/apache-tomcat-9.0.80/bin/startup.sh
[Install]
WantedBy = multi-user.target
- name: chmod 755 tomcat.service
file:
path: /etc/systemd/system/tomcat.service
mode: 0755
- name: start tomcat
systemd:
name: tomcat.service
state: started
daemon_reload: yes
enabled: yes