-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunsetupWildfly.yml
142 lines (118 loc) · 3.68 KB
/
runsetupWildfly.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
---
- hosts: all
become: true
ignore_errors: true
vars:
javaVersion: jdk1.8.0_131
javaDownload: https://satellite.cdmx.gob.mx/pub/java/jdk-8u131-linux-x64.tar.gz
wildflyDownload: https://satellite.cdmx.gob.mx/pub/wildfly/wildfly-17.0.1.Final.tar.gz
tasks:
- name: Prepare system
block:
- name: Update system
yum:
name: "*"
state: latest
- name: setting up firewall ports
firewalld:
permanent: true
immediate: true
port: "{{item}}"
state: enabled
with_items:
- 8080/tcp
- 9990/tcp
- name: Java config
block:
- name: Create a java directory if it does not exist
file:
path: /opt/apps/java
state: directory
- name: Extract {{javaVersion}} into /opt/apps
unarchive:
src: "{{javaDownload}}"
dest: /opt/apps/java/
remote_src: yes
- name: Install wildfly
block:
- name: Create group Wildfly
group:
name: wildfly
state: present
- name: Create user and add to group Wildfly'
user:
name: wildfly
shell: /sbin/nologin
home: /opt/apps/wildfly
group: wildfly
- name: Extract wildfly.tgz into /opt/
unarchive:
src: "{{wildflyDownload}}"
dest: /opt/apps/wildfly
remote_src: yes
extra_opts: [--strip-components=1]
- name: Ensure JAVA_HOME is set to /opt/apps/java
lineinfile:
path: /opt/apps/wildfly/bin/standalone.conf
regexp: '^#JAVA_HOME='
line: JAVA_HOME="/opt/apps/java/{{javaVersion}}"
- name: Recursively change ownership of a /opt/wildfly
file:
path: /opt/apps/wildfly
state: directory
recurse: yes
owner: wildfly
group: wildfly
- name: Copy config files for wildfly deploy
block:
- name: Create a directory if it does not exist
file:
path: /etc/wildfly
state: directory
- name: Copy wildfly.conf with owner and permissions
copy:
src: /opt/apps/wildfly/docs/contrib/scripts/systemd/wildfly.conf
dest: /etc/wildfly/
remote_src: yes
- name: Copy launch.sh with owner and permissions
copy:
src: /opt/apps/wildfly/docs/contrib/scripts/systemd/launch.sh
dest: /opt/apps/wildfly/bin/
remote_src: yes
- name: Copy wildfly.service with owner and permissions
copy:
src: /opt/apps/wildfly/docs/contrib/scripts/systemd/wildfly.service
dest: /etc/systemd/system/
remote_src: yes
tags:
- copyfiles
- name: config files
block:
- name: Ensure WILDFLY_HOME is set to /opt/apps/wildfly
lineinfile:
path: /opt/apps/wildfly/bin/launch.sh
regexp: '[^\s]*WILDFLY_HOME='
line: ' WILDFLY_HOME="/opt/apps/wildfly"'
- name: Ensure ExecStart is set to /opt/apps/wildfly/bin/launch.sh
lineinfile:
path: /etc/systemd/system/wildfly.service
regexp: '^ExecStart='
line: ExecStart=/opt/apps/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
- name: Change launch.sh permissions
file:
path: /opt/apps/wildfly/bin/launch.sh
mode: '+x'
tags:
- configFiles
- name: Start services
block:
- name: daemon-reload to pick up config changes
systemd:
daemon_reload: yes
- name: start wildfly Service
service:
name: wildfly
state: started
enabled: yes
tags:
- configFiles