forked from Lion-Technology-Solutions/ansible-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
11-installtomcat10.yaml
72 lines (72 loc) · 2.2 KB
/
11-installtomcat10.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: tomcatservers
become: true
tasks:
- name: Install Java
yum:
name: java-1.8.0-openjdk
state: present
- name: add tomcatuser
user:
name: tomcat
shell: /sbin/nologin
- name: Tomcat-10 Installation
get_url:
url: https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.8/bin/apache-tomcat-10.1.8.tar.gz
dest: /tmp/
- name: copy
copy:
src: /tmp/apache-tomcat-10.1.8.tar.gz
dest: /usr/local/
remote_src: yes
- name: Unpacking the archive
unarchive:
src: /usr/local/apache-tomcat-10.1.8.tar.gz
dest: /usr/local
remote_src: yes
- name: Change file ownership, group and permissions
file:
path: /usr/local/apache-tomcat-10.1.8
owner: tomcat
group: tomcat
recurse: yes
state: directory
- name: make tomcat symbolic link
file:
src: /usr/local/apache-tomcat-10.1.8
dest: /usr/local/tomcat7
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 10
After = syslog.target network.target
[Service]
User = tomcat
Group = tomcat
Type = oneshot
PIDFile =/usr/local/apache-tomcat-10.1.8/tomcat.pid
RemainAfterExit = yes
ExecStart =/usr/local/apache-tomcat-10.1.8/bin/startup.sh
ExecStop =/usr/local/apache-tomcat-10.1.8/bin/shutdown.sh
ExecReStart =/usr/local/apache-tomcat-10.1.8/bin/shutdown.sh;/usr/local/apache-tomcat-10.1.8/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