-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_test_server.yml
295 lines (264 loc) · 10.4 KB
/
create_test_server.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
---
# ------------------------------------------------------------------------------
# Installs and configures an Oracle 19C database on DURAL as a test server
# ------------------------------------------------------------------------------
- name: "Creates a test database server on DURAL"
hosts: database
tasks:
- name: "Set global variables"
set_fact:
response_file: "{{ oracle_user_home }}/db_install.rsp"
# ----------------------------------------------------------------------------
# Load passwords from passwords/oracle.yml which has the following variables:
# * pw_all
# * pw_sys
# * pw_system
# * pw_pdbadmin
#
# >>>>>>> This file is deliberately NOT included in the GIT repository <<<<<<<
# ----------------------------------------------------------------------------
- name: "Load passwords"
include_vars:
file: "passwords/oracle.yml"
no_log: true
# ----------------------------------------------------------------------------
# The Oracle 19C preinstallation RPM should only be installed once, even if
# a more newer version exists as the RPM creates users and does system
# configuration.
# ----------------------------------------------------------------------------
- name: "Install Oracle Preinstallation RPM"
yum:
name: oracle-database-preinstall-19c
state: present
become: yes
become_user: root
- name: "Create files for silent installation"
template:
src: "{{ item.dest | basename }}.j2"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
become: yes
become_user: oracle
with_items:
- { dest: "{{ response_file }}", mode: "0600" }
- { dest: "{{ sw_installer }}", mode: "0700" }
- { dest: "{{ config_tools }}", mode: "0700" }
- { dest: "{{ apply_patches }}", mode: "0700" }
- name: "Create directory for Installation Software"
file:
name: "{{ oracle_home }}"
group: "{{ install_group }}"
owner: oracle
state: directory
mode: 0775
become: yes
become_user: root
- name: "Checks the existence of {{ oracle_home }}"
stat:
path: "{{ oracle_home }}"
register: oracle_home_path
- name: "Extract the Oracle Software Installer"
unarchive:
creates: "{{ oracle_home }}/runInstaller"
dest: "{{ oracle_home }}"
group: "{{ install_group }}"
owner: oracle
remote_src: yes
src: "{{ sw_archive }}"
become: yes
become_user: oracle
when:
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- name: "Create directory for Patches"
file:
name: "{{ oracle_home }}/patch"
group: "{{ install_group }}"
owner: oracle
state: directory
mode: 0775
become: yes
become_user: oracle
when:
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- name: "Extract the patches"
unarchive:
creates: "{{ patch_directory }}"
dest: "{{ oracle_home }}/patch"
group: "{{ install_group }}"
owner: oracle
remote_src: yes
src: "{{ patch_archive }}"
become: yes
become_user: oracle
when:
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- name: "Check existence of OPatch"
stat:
path: "{{ opatch_bin }}"
register: opatch
become: yes
become_user: oracle
- name: "Check if db s/w has been installed"
command:
argv:
- "{{ opatch_bin }}"
- lsinventory
- "-oh"
- "{{ oracle_home }}"
failed_when: false
changed_when: false
register: db_sw_installed
become: yes
become_user: oracle
when:
- opatch.stat is defined
- opatch.stat.exists
- name: "Display inventory listing for OH={{ oracle_home }}"
debug:
var: db_sw_installed.stdout_lines
when: db_sw_installed.stdout_lines is defined
- name: "Install Oracle DB Software in Silent Mode"
command:
argv:
- "{{ sw_installer }}"
chdir: "{{ oracle_home }}"
register: db_install_result
become: yes
become_user: oracle
failed_when: false
when:
- opatch.stat is defined
- opatch.stat.exists
- db_sw_installed.stdout is defined
- db_sw_installed.stdout is not search("Oracle Database 19c")
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- name: "Output from Install Oracle DB Software in Silent Mode"
debug:
var: db_install_result.stdout_lines
verbosity: 0
when: db_install_result.stdout_lines is defined
- name: "Run orainstRoot.sh after Oracle Database Software Installation"
command:
argv:
- "{{ inventory_location }}/orainstRoot.sh"
register: orainstRoot
when:
- db_install_result.stdout is defined
- db_install_result.stdout is search('/orainstRoot.sh')
become: yes
become_user: root
- name: "Output from orainstRoot.sh script"
debug:
var: orainstRoot.stdout_lines
verbosity: 0
when: orainstRoot.stdout_lines is defined
- name: "Run root.sh after Oracle Database Software Installation"
command:
argv:
- "{{ oracle_home }}/root.sh"
register: db_root
when:
- db_install_result.stdout is defined
- db_install_result.stdout is search('/root.sh')
become: yes
become_user: root
- name: "Output from root.sh script"
debug:
var: db_root.stdout_lines
verbosity: 0
when: db_root.stdout_lines is defined
- name: "Complete the configuration"
command:
argv:
- "{{ oracle_home }}/runInstaller"
- "-executeConfigTools"
- "-responseFile"
- "{{ response_file }}"
- "-silent"
register: executeConfigTools
when:
- db_install_result.stdout is defined
- db_install_result.stdout is search('-executeConfigTools')
become: yes
become_user: oracle
- name: "Output from executeConfigTools script"
debug:
var: executeConfigTools.stdout_lines
verbosity: 0
when: executeConfigTools.stdout_lines is defined
- name: "Get current version of OPatch"
command:
argv:
- "{{ opatch_bin }}"
- version
chdir: "{{ oracle_home }}/OPatch"
register: opatch_vers_data
changed_when: false
become: yes
become_user: oracle
when:
- opatch.stat is defined
- opatch.stat.exists
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- name: "Extract version of OPatch from command output"
set_fact:
opatch_version: "{{ opatch_vers_data.stdout_lines[0].split(' ')[2] }}"
when: opatch_vers_data.stdout_lines is defined
- name: "Install latest version of OPatch (P6880880)"
unarchive:
dest: "{{ oracle_home }}"
owner: oracle
group: "{{ install_group }}"
remote_src: yes
src: "/opt/share/Software/OPatch/p6880880_190000_Linux-x86-64.zip"
become: yes
become_user: oracle
when:
- opatch_version is defined
- opatch_version is version(min_opatch_vers, operator='lt', strict=false)
- name: "Check if patches from {{ patch_directory }} hav been applied"
command:
argv:
- "{{ opatch_bin }}"
- lspatches
- "-verify"
- "-oh"
- "{{ oracle_home }}"
- "{{ patch_directory }}"
failed_when: false
changed_when: false
register: patch_applied
become: yes
become_user: oracle
when:
- opatch.stat.exists
- name: "Status of patches in Oracle Home"
debug:
var: patch_applied.stdout_lines
when: patch_applied.stdout_lines is defined
- name: "Patch Oracle DB Software"
command:
argv:
- "{{ apply_patches }}"
chdir: "{{ oracle_home }}"
failed_when: false
register: opatch_apply
when:
- opatch.stat is defined
- opatch.stat.exists
- oracle_home_path.stat is defined
- oracle_home_path.stat.exists
- patch_applied.stdout is defined
- patch_applied.stdout is search(' NOT registered in Oracle Home')
become: yes
become_user: oracle
- name: "Output from apply of patches into Oracle Home"
debug:
var: opatch_apply.stdout_lines
when: opatch_apply.stdout_lines is defined
...