-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtomcat_deploy.yml
82 lines (74 loc) · 2.14 KB
/
tomcat_deploy.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
---
- hosts : localhost
connection : local
become : true
vars :
env : "{{env}}"
ansible_python_interpreter: /usr/bin/python3
tasks :
- name : Installing Java 8
apt :
name : openjdk-8-jdk
state : present
update_cache : yes
- name: add tomcat group
group:
name: tomcat
- name: add tomcat user
user:
name: tomcat
group: tomcat
#home: /user/share/tomcat
#createhome: no
- name: create /opt/tomcat directory
file:
path: /opt/tomcat
state: directory
mode: 0755
- name: download tomcat 9
get_url:
url : https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz
dest: /opt/tomcat
- name: extract tomcat packages
unarchive:
src: /opt/tomcat/apache-tomcat-9.0.56.tar.gz
dest: /opt/tomcat
remote_src: yes
extra_opts: [--strip-components=1]
- name: Change ownership
file:
path: /opt/tomcat
owner: tomcat
group: tomcat
mode: "u+rwx,g+rx,o=rx"
recurse: yes
state: directory
- name: Deploying sample.war on tomcat Server
ansible.builtin.copy :
src : /data/sample.war
dest : /opt/tomcat/webapps
- name: Copy Tomcat service from local to remote
copy:
src: tomcat9.service
dest: /etc/systemd/system/
mode: 0755
- name: testing if environement (Dev )
lineinfile :
path : /etc/systemd/system/tomcat9.service
search_string : '-Xmx1024M'
line : Environment='CATALINA_OPTS=-Xms128M -Xmx256M -server -XX:+UseParallelGC'
when : env == 'DEV'
- name: testing if environement is Prod
lineinfile :
path : /etc/systemd/system/tomcat9.service
search_string : '-Xmx1024M'
line : Environment='CATALINA_OPTS=-Xms256M -Xmx512M -server -XX:+UseParallelGC'
when : env == 'PROD'
- name: Start and enable Tomcat service
systemd:
name: tomcat9
state: started
enabled: true
daemon_reload: true
# - name: start tomcat services
#shell: nohup /usr/local/apache-tomcat-9.0.44/bin/startup.sh