-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.6.0-afs-mounts.yml
392 lines (352 loc) · 17.2 KB
/
2.6.0-afs-mounts.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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
---
# /*---------------------------------------------------------------------------8
# | |
# | Perform the AFS system mounts |
# | |
# +------------------------------------4--------------------------------------*/
- name: "calling setting variables python script"
setting_vars:
sap_id: "{{ sap_id }}"
hdbadm_uid: "{{ hdbadm_uid }}"
platform: "{{ platform }}"
sidadm_uid: "{{ sidadm_uid }}"
multi_sids: "{{ multi_sids | default(omit) }}"
asesidadm_uid: "{{ asesidadm_uid | default(omit)}}"
scs_instance_number: "{{ scs_instance_number }}"
pas_instance_number: "{{ pas_instance_number }}"
app_instance_number: "{{ app_instance_number }}"
list_of_servers: "{{ list_of_servers }}"
tags:
- test
register: check
#delegate_to: DESKTOP-B47NF4I
- name: "AFS Mount: Create list of all_sap_mounts to support"
ansible.builtin.debug:
msg:
#- "{{ check.stdout.split }}"
- "{{check.stdout.splitlines() | map('from_yaml') | list }}"
#- "List of all the SAP mounts: {{ all_sap_mounts }}"
#- "First server: {{ first_server_temp }}"
#verbosity: 2
tags:
- test
# /*---------------------------------------------------------------------------8
# | |
# | Prepare for the sap_mnt mounts |
# | Create temporary directory structure |
# | Mount the share, create the directory structure on share |
# | Unmount and clean up temporary directory structure |
# | |
# +------------------------------------4--------------------------------------*/
- name: "AFS Mount: Create local directories"
block:
- name: "AFS Mount: sap_mnt"
block:
- name: "AFS Mount: Create /saptmp"
ansible.builtin.file:
path: "/saptmp"
state: directory
group: sapsys
mode: 0755
# Mount Filesystem on AFS
# This is needed so that we can create the correct directory
- name: "AFS Mount: sap_mnt (preparation)"
block:
- name: "AFS Mount: sap_mnt (preparation)"
ansible.posix.mount:
src: "{{ sap_mnt }}"
path: "/saptmp"
fstype: "nfs4"
opts: "{{ afs_mnt_options }}"
state: mounted
rescue:
- name: "Rescue - AFS Mount: sap_mnt (preparation) - logging"
ansible.builtin.debug:
msg: "Rescue - AFS Mount: sap_mnt (preparation)"
- name: "Rescue - AFS Mount: sap_mnt - Pause for 5 seconds"
ansible.builtin.pause:
seconds: 15
- name: "Rescue - AFS Mount: sap_mnt (preparation)"
ansible.posix.mount:
src: "{{ sap_mnt }}"
path: "/saptmp"
fstype: "nfs4"
opts: "{{ afs_mnt_options }}"
state: mounted
- name: "AFS Mount: Create SAP Directories (AFS)"
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: '{% if platform == "SYBASE" %}{{ asesidadm_uid }}{% else %}{{ sapadm_uid }}{% endif %}'
group: sapsys
mode: 0755
loop:
- { path: '/saptmp/usrsap{{ sap_sid | upper }}' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}{{ instance_type | lower }}{{ scs_instance_number }}' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}ers{{ ers_instance_number }}' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}sys' }
- name: "AFS Mount: Create SAP Directories (AFS)"
ansible.builtin.file:
path: "/saptmp/sapmnt{{ item.sid | upper }}"
state: directory
owner: '{{ item.sidadm_uid }}'
group: sapsys
mode: 0755
loop: "{{ all_sap_mounts }}"
- name: "AFS Mount: Unmount file systems (sapmnt)"
ansible.posix.mount:
src: "{{ sap_mnt }}"
path: "/saptmp"
state: unmounted
- name: "AFS Mount: Delete locally created SAP Directories (sapmnt)"
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop:
- { path: '/saptmp/usrsap{{ sap_sid | upper }}{{ instance_type | lower }}{{ scs_instance_number }}' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}ers{{ ers_instance_number }}' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}sys' }
- { path: '/saptmp/usrsap{{ sap_sid | upper }}' }
- name: "AFS Mount: Remove /saptmp/sapmnt (AFS)"
ansible.builtin.file:
path: "/saptmp/sapmnt{{ item.sid | upper }}"
state: absent
loop: "{{ all_sap_mounts }}"
- name: "AFS Mount: Cleanup fstab and directory (sapmnt)"
ansible.posix.mount:
src: "{{ sap_mnt }}"
path: "/saptmp"
fstype: "nfs4"
opts: "{{ afs_mnt_options }}"
state: absent
when:
- sap_mnt is defined
when:
- tier == 'sapos'
- "'scs' in supported_tiers"
- sap_mnt is defined
- name: "AFS Mount: install"
ansible.builtin.include_tasks: 2.6.0.1-afs-mount.yaml
loop:
- {
'type': 'install',
'temppath': 'sapinstall',
'folder': '{{ bom_base_name }}',
'mount': '{{ usr_sap_install_mountpoint }}',
'opts': 'rw,hard,rsize=1048576,wsize=1048576,noresvport,actimeo=60,vers=4,minorversion=1,sec=sys',
'path': '/usr/sap/install',
'permissions': '0777',
'set_chattr_on_dir': false,
'target_nodes': ['all'],
'create_temp_folders': true
}
vars:
primary_host: "{{ first_server_temp | first }}"
when:
- tier == 'sapos'
- usr_sap_install_mountpoint is defined
- name: "AFS Mount: sap_mnt"
block:
- name: "AFS Mount: Create SAP Directories (sapmnt)"
ansible.builtin.file:
owner: '{{ item.sidadm_uid }}'
group: sapsys
mode: 0755
path: "/sapmnt/{{ item.sid }}"
state: directory
register: is_created_now
loop: "{{ all_sap_mounts }}"
- name: "AFS Mount: Change attribute only when we create SAP Directories (sapmnt)"
ansible.builtin.file:
path: "{{ item.item.path }}"
state: directory
mode: 0755
attr: i+
loop: "{{ is_created_now.results }}"
when:
- item.item is changed
register: set_immutable_attribute
when:
- tier == 'sapos'
- node_tier != 'hana'
- sap_mnt is defined
# /*---------------------------------------------------------------------------8
# | |
# | Perform the sap_mnt mounts |
# | Create directories and make them immutable |
# | |
# +------------------------------------4--------------------------------------*/
- name: "AFS Mount: sap_mnt (scs & ers)"
block:
- name: "AFS Mount: Create SAP Directories (scs & ers)"
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: '{% if platform == "SYBASE" %}{{ asesidadm_uid }}{% else %}{{ sapadm_uid }}{% endif %}'
group: sapsys
mode: 0755
loop:
- { path: '/usr/sap/{{ sap_sid | upper }}' }
- { path: '/usr/sap/{{ sap_sid | upper }}/SYS' }
- { path: '/usr/sap/{{ sap_sid | upper }}/{{ instance_type | upper }}{{ scs_instance_number }}' }
- { path: '/usr/sap/{{ sap_sid | upper }}/ERS{{ ers_instance_number }}' }
register: is_created_now3
- name: "AFS Mount: Change attribute only when we create SAP Directories (scs & ers)"
ansible.builtin.file:
path: "{{ item.item.path }}"
state: directory
mode: 0755
attr: i+
loop: "{{ is_created_now3.results }}"
when:
- item.item is changed
register: set_immutable_attribute
when:
- tier == 'sapos'
- "'scs' in supported_tiers or 'ers' in supported_tiers "
- sap_mnt is defined
- MULTI_SIDS is undefined
- name: "AFS Mount Debug"
ansible.builtin.debug:
msg:
- "{{ not scs_high_availability }}"
- "{{ node_tier != 'hana' }}"
- "{{ sap_mnt is defined }}"
- "{{ MULTI_SIDS is undefined }}"
verbosity: 4
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
block:
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
opts: "{{ afs_mnt_options }}"
state: mounted
loop:
- { type: 'nfs4', src: '{{ sap_mnt }}/sapmnt{{ sap_sid | upper }}', path: '/sapmnt/{{ sap_sid | upper }}' }
rescue:
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
opts: "{{ afs_mnt_options }}"
state: unmounted
loop:
- { type: 'nfs4', src: '{{ sap_mnt }}/sapmnt{{ sap_sid | upper }}', path: '/sapmnt/{{ sap_sid | upper }}' }
- name: "AFS Mount: Pause for 15 seconds"
ansible.builtin.pause:
seconds: 15
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
ansible.builtin.debug:
msg: "Rescue - AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone"
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
opts: "{{ afs_mnt_options }}"
state: mounted
loop:
- { type: 'nfs4', src: '{{ sap_mnt }}/sapmnt{{ sap_sid | upper }}', path: '/sapmnt/{{ sap_sid | upper }}' }
when:
- not scs_high_availability
- node_tier != 'hana'
- sap_mnt is defined
- MULTI_SIDS is undefined
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} - Standalone MULTI_SIDS"
become: true
become_user: root
ansible.posix.mount:
src: "{{ sap_mnt }}/sapmnt{{ item.sid }}"
path: "/sapmnt/{{ item.sid }}"
fstype: 'nfs4'
opts: "{{ afs_mnt_options }}"
state: mounted
loop: "{{ MULTI_SIDS }}"
when:
- not scs_high_availability
- sap_mnt is defined
- MULTI_SIDS is defined
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} HA"
block:
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} HA"
ansible.posix.mount:
src: "{{ sap_mnt }}/sapmnt{{ sap_sid | upper }}"
path: "/sapmnt/{{ sap_sid | upper }}"
fstype: nfs4
opts: "{{ afs_mnt_options }}"
state: mounted
rescue:
- name: "AFS Mount: Pause for 15 seconds"
ansible.builtin.pause:
seconds: 15
- name: "AFS Mount: sapmnt/{{ sap_sid | upper }} HA"
ansible.posix.mount:
src: "{{ sap_mnt }}/sapmnt{{ sap_sid | upper }}"
path: "/sapmnt/{{ sap_sid | upper }}"
fstype: nfs4
opts: "{{ afs_mnt_options }}"
state: mounted
when:
- scs_high_availability
- node_tier != 'hana'
- sap_mnt is defined
- name: "AFS Mount: usr/sap/{{ sap_sid | upper }}/SYS"
block:
- name: "AFS Mount: usr/sap/{{ sap_sid | upper }}/SYS"
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
opts: 'rw,hard,rsize=65536,wsize=65536,sec=sys,vers=4.1,tcp'
state: mounted
register: sys_mounted
loop:
- { type: 'nfs4', src: '{{ sap_mnt }}/usrsap{{ sap_sid | upper }}sys', path: '/usr/sap/{{ sap_sid | upper }}/SYS' }
rescue:
- name: "AFS Mount: Pause for 15 seconds"
ansible.builtin.pause:
seconds: 15
- name: "AFS Mount: usr/sap/{{ sap_sid | upper }}/SYS"
ansible.builtin.debug:
msg: "Rescue - AFS Mount: usr/sap/{{ sap_sid | upper }}/SYS"
- name: "AFS Mount: Debug"
ansible.builtin.debug:
var: sys_mounted
- name: "AFS Mount: usr/sap/{{ sap_sid | upper }}/SYS"
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
opts: "{{ afs_mnt_options }}"
state: mounted
loop:
- { type: 'nfs4', src: '{{ sap_mnt }}/usrsap{{ sap_sid | upper }}sys', path: '/usr/sap/{{ sap_sid | upper }}/SYS' }
when:
- scs_high_availability
- node_tier in ['scs','ers']
- sap_mnt is defined
tags:
- sap_app_ha_sys_mount
- name: "AFS Mount: sap_trans"
ansible.builtin.include_tasks: 2.6.0.1-afs-mount.yaml
loop:
- {
'type': 'trans',
'temppath': 'saptrans',
'mount': '{{ sap_trans }}',
'opts': '{{ afs_mnt_options }}',
'path': '/usr/sap/trans',
'permissions': '0775',
'set_chattr_on_dir': false,
'target_nodes': ['app','pas', 'ers', 'scs'],
'create_temp_folders': false
}
vars:
primary_host: "{{ first_server_temp | first }}"
when:
- tier == 'sapos'
- sap_trans is defined
...