forked from Azure/sap-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.6.0-afs-mounts.yaml
More file actions
477 lines (429 loc) · 20.9 KB
/
2.6.0-afs-mounts.yaml
File metadata and controls
477 lines (429 loc) · 20.9 KB
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
---
# /*---------------------------------------------------------------------------8
# | |
# | Perform the AFS system mounts |
# | |
# +------------------------------------4--------------------------------------*/
- name: "AFS Mount: Define this SID"
ansible.builtin.set_fact:
this_sid:
{
'sid': '{{ sap_sid | upper }}',
'dbsid_uid': '{{ hdbadm_uid }}',
'sidadm_uid': '{% if platform == "SYBASE" %}{{ asesidadm_uid }}{% else %}{{ sidadm_uid }}{% endif %}',
'ascs_inst_no': '{{ scs_instance_number }}',
'pas_inst_no': '{{ pas_instance_number }}',
'app_inst_no': '{{ app_instance_number }}'
}
- name: "AFS Mount: Create list of all_sap_mounts to support "
ansible.builtin.set_fact:
all_sap_mounts: "{% if MULTI_SIDS is defined %}{{ MULTI_SIDS }}{% else %}{{ all_sap_mounts | default([]) + [this_sid] }}{% endif %}"
- name: "AFS Mount: Get the Server name list"
ansible.builtin.set_fact:
first_server_temp: "{{ first_server_temp | default([]) + [item] }}"
with_items:
- "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_SCS') }}"
- "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_DB') }}"
# The afs_mnt_options_default captures the baseline AFS mount options.
# If afs_mnt_options has been pre-set (e.g. with additional hardening options),
# it will be preserved. This allows consumers to extend mount options while
# keeping the baseline available for computing deltas downstream.
- name: "AFS Mount: Set the AFS mount options baseline"
ansible.builtin.set_fact:
afs_mnt_options_default: 'noresvport,vers=4,minorversion=1,sec=sys'
- name: "AFS Mount: Set the NFSmount options"
ansible.builtin.set_fact:
afs_mnt_options: "{{ afs_mnt_options | default(afs_mnt_options_default) }}"
- name: "AFS Mount: Create list of all_sap_mounts to support"
ansible.builtin.debug:
msg:
- "List of all the SAP mounts: {{ all_sap_mounts }}"
- "First server: {{ first_server_temp }}"
verbosity: 2
- name: "AFS Mount: Create configuration file
with additional optimization settings"
ansible.builtin.blockinfile:
path: /etc/sysctl.d/ms-az.conf
backup: true
create: true
mode: 0644
marker: "# {mark} HANA AFS optimizations"
block: |
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv4.tcp_max_syn_backlog = 16348
net.ipv4.conf.all.rp_filter = 0
sunrpc.tcp_slot_table_entries = 128
vm.swappiness=10
when:
- node_tier == 'hana'
# /*---------------------------------------------------------------------------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',
'owner': '{{ sidadm_uid }}',
'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
- usr_sap_install_mountpoint != ''
- 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 not in ['hana' , 'observer']
- 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 not in ['hana' , 'observer']
- 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',
'owner': "root",
'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
- sap_trans != ''
# Scale out - shared nothing configuration code to support AFS based /hana/shared mount
- name: "AFS Mount: Scale out hana_shared"
ansible.builtin.include_tasks: 2.6.0.1-afs-mount.yaml
loop:
- {
'type': 'shared',
'temppath': 'shared',
'mount': "{% if site | default('SITE1') == 'SITE1' %}{{ hana_shared_mountpoint[0] }}{% else %}{{ hana_shared_mountpoint[1] }}{% endif %}",
'opts': '{{ afs_mnt_options }}',
'path': '/hana/shared',
'owner': '{{ sidadm_uid }}',
'permissions': '0775',
'set_chattr_on_dir': false,
'target_nodes': ['hana'],
'create_temp_folders': false
}
vars:
primary_host: "{{ ansible_hostname }}"
when:
- database_scale_out
- database_high_availability
- hana_shared_mountpoint is defined
- hana_shared_mountpoint | length == 2
- name: "AFS Mount: Scale out hana_shared"
ansible.builtin.include_tasks: 2.6.0.1-afs-mount.yaml
loop:
- {
'type': 'shared',
'temppath': 'shared',
'mount': "{{ hana_shared_mountpoint[0] }}",
'opts': '{{ afs_mnt_options }}',
'path': '/hana/shared',
'owner': '{{ sidadm_uid }}',
'permissions': '0775',
'set_chattr_on_dir': false,
'target_nodes': ['hana'],
'create_temp_folders': false
}
vars:
primary_host: "{{ ansible_hostname }}"
when:
- database_scale_out
- not database_high_availability
- hana_shared_mountpoint is defined
- hana_shared_mountpoint | length == 1
...