-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_asm_install.yaml
732 lines (646 loc) · 26.3 KB
/
2_asm_install.yaml
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# Work in Progress!
---
- name: Configure server - Oracle DB install.
hosts: "{{ hosts | default('db_servers') }}"
vars:
v_maj: "{{ oracle_version.split('.') | first | string }}"
v_maj_min: "{{ oracle_version.split('.')[:2] | join('.') | string }}"
tasks:
- name: Create groups for ASM.
tags: user_mgmt, groups, asm
ansible.builtin.group:
name: "{{ item.group }}"
gid: "{{ item.gid }}"
loop:
- { group: asmdba, gid: 1003 }
- { group: asmoper, gid: 1004 }
- { group: asmadmin, gid: 1005 }
when: asm_setup
- name: Create grid user and add to ASM groups.
tags: user_mgmt, groups, users
ansible.builtin.user:
name: "{{ grid_user }}"
password: "{{ grid_pass | password_hash('sha512') }}"
group: oinstall
groups: "asmadmin,asmdba,asmoper"
append: true
update_password: on_create
when: asm_setup
- name: Create directories for ASM.
tags: user_mgmt, users, dir
ansible.builtin.file:
path: "{{ grid_home }}"
state: directory
owner: "{{ grid_user }}"
group: oinstall
mode: '775'
recurse: true
when: asm_setup
- name: Add info to root and oracle user's .bash_profiles.
tags: user_mgmt, users
ansible.builtin.lineinfile:
path: "{{ item.path }}"
line: "{{ item.line }}"
regexp: "{{ item.regexp | default('none') }}"
create: true
owner: "{{ item.owner }}"
group: "{{ item.group }}"
loop:
- { path: "/home/{{ grid_user }}/.bash_profile", line: "export GRID_HOME={{ grid_home }}", regexp: 'export GRID_HOME=', owner: "{{ grid_user }}", group: oinstall }
- { path: "/home/{{ grid_user }}/.bash_profile", line: "{{ 'export ORACLE_HOME=' + grid_home }}", regexp: 'export ORACLE_HOME=', owner: "{{ grid_user }}", group: oinstall }
- { path: "/home/{{ grid_user }}/.bash_profile", line: "CVUQDISK_GRP=oinstall; export CVUQDISK_GRP", regexp: "CVUQDISK_GRP", owner: "{{ grid_user }}", group: oinstall }
- { path: "/root/.bash_profile", line: "export GRID_HOME={{ grid_home }}", regexp: 'export GRID_HOME=', owner: root, group: root }
- { path: "/root/.bash_profile", line: "{{ 'export ORACLE_HOME=' + grid_home }}", regexp: 'export ORACLE_HOME=', owner: root, group: root }
- { path: "/root/.bash_profile", line: "CVUQDISK_GRP=oinstall; export CVUQDISK_GRP", regexp: "CVUQDISK_GRP", owner: root, group: root }
when: asm_setup
- name: Ensure grid home directory exists.
tags: pre, asm
ansible.builtin.file:
path: "{{ grid_home }}"
state: directory
when: asm_setup
# - name: Add SSH key to grid user's authorized_keys file.
# tags: oracle, ssh_copy_id, authorized_keys
# ansible.builtin.authorized_key:
# user: "{{ grid_user }}"
# state: present
# key: "{{ lookup('file', ansible_ssh_private_key_file + '.pub') }}"
- name: Unzip Grid home.
tags: pre, asm, zip
ansible.builtin.unarchive:
src: "{{ grid_zip }}"
dest: "{{ grid_home }}"
creates: "{{ grid_home }}/cv"
remote_src: true
owner: "{{ oracle_user }}"
group: oinstall
mode: '775'
when: asm_setup
- name: Ensure all files within grid home have proper ownership after unzip.
tags: pre, asm
ansible.builtin.file:
path: "{{ grid_home }}"
state: directory
owner: "{{ oracle_user }}"
group: oinstall
recurse: true
when: asm_setup
- name: Install cvuqdisk RPM.
tags: pre, asm
ansible.builtin.dnf:
name: "{{ grid_cvuqdisk_rpm }}"
disable_gpg_check: true
when: asm_setup and install_rpms
- name: Stop avahi-daemon, as recommended.
tags: pre, asm
ansible.builtin.service:
name: avahi-daemon
state: stopped
enabled: false
when: asm_setup
- name: Disable the Zeroconf network configuration feature, as recommended.
tags: pre, asm
ansible.builtin.lineinfile:
path: /etc/sysconfig/network
backup: true
line: "NOZEROCONF=yes"
regexp: "NOZEROCONF="
notify: Restart NetworkManager
when: asm_setup
- name: Configure Network Time Protocol (NTP), as recommended (1/3) - install package.
tags: pre, asm
ansible.builtin.package:
name: chrony
when: asm_setup
- name: Configure Network Time Protocol (NTP), as recommended (2/3) - set firewall.
tags: pre, asm
ansible.posix.firewalld:
service: ntp
permanent: yes
state: enabled
notify: Reload firewall
when: asm_setup
- name: Configure Network Time Protocol (NTP), as recommended - set NTP server (3/3).
tags: pre, asm
ansible.builtin.lineinfile:
path: /etc/chrony.conf
backup: true
line: "server {{ ntp_server }} iburst"
regexp: ^.*server.*iburst.*$
notify: Restart chronyd
when: asm_setup
- name: Create swap space, if requested (1/9) - create and zero out swap file.
tags: pre, asm, swap
ansible.builtin.command:
cmd: "dd if=/dev/zero of={{ swap_path }} bs=1M count={{ swap_size }}"
creates: "{{ swap_path }}"
when: swap_create and asm_setup
- name: Create swap space, if requested (2/9) - set permissions.
tags: pre, asm, swap
ansible.builtin.file:
path: "{{ swap_path }}"
owner: root
group: root
mode: '600'
when: swap_create and asm_setup
- name: Create swap space, if requested (3/9) - check if swap space already exists.
tags: pre, asm, swap
ansible.builtin.shell: "file {{ swap_path }} | awk -F':' '{print $2}' | grep -q swap"
register: swap_exists
failed_when: swap_exists.rc > 1
changed_when: false
when: swap_create and asm_setup
- name: Create swap space, if requested (4/9) - make swap space.
tags: pre, asm, swap
ansible.builtin.command: "mkswap {{ swap_path }}"
when: swap_create and swap_exists.rc == 1 and asm_setup
- name: Create swap space, if requested (5/9) - check if swap is already on
tags: pre, asm, swap
ansible.builtin.shell: "swapon -s | grep {{ swap_path }}"
register: swap_on
changed_when: false
failed_when: swap_on.rc > 1
when: swap_create and asm_setup
- name: Create swap space, if requested (6/9) - initalize swap space.
tags: pre, asm, swap
ansible.builtin.command: "swapon {{ swap_path }}"
when: swap_create and swap_on.rc == 1 and asm_setup
- name: Create swap space, if requested (7/9) - write swap entry in fstab.
tags: pre, asm, swap
ansible.posix.mount:
path: none
src: "{{ swap_path }}"
state: present
fstype: swap
opts: sw
when: swap_create and asm_setup
- name: Create swap space, if requested (8/9) - check created swap space.
tags: pre, asm, swap
ansible.builtin.command: "free -h"
changed_when: false
register: check_swap
when: swap_create and asm_setup
- name: Create swap space, if requested (9/9) - print swap space info for debugging/verification.
tags: pre, asm, swap
ansible.builtin.debug:
msg: "{{ check_swap.stdout_lines }}"
when: swap_create and asm_setup
- name: Setup disk for ASM.
tags: always
ansible.builtin.include_role:
name: asm
tasks_from: "{{ asm_disk_type }}.yaml"
when: asm_setup
- name: Reboot db servers.
tags: disk, asm, reboot
ansible.builtin.reboot:
- name: Get lsblk output for debugging/verification.
tags: disk, asm
ansible.builtin.command: lsblk --fs
register: lsblk_check
changed_when: false
when: asm_setup
- name: Print lsblk output for debugging/verification.
tags: disk, asm
ansible.builtin.debug:
msg: "{{ lsblk_check.stdout_lines }}"
when: asm_setup
- name: Unzip new OPatch to replace old.
tags: asm
ansible.builtin.unarchive:
src: "{{ grid_opatch_zip }}"
dest: "{{ grid_home }}"
remote_src: true
when: asm_setup
- name: Ensure all files within grid home have proper ownership after unzip.
tags: pre, asm
ansible.builtin.file:
path: "{{ grid_home }}"
state: directory
owner: "{{ grid_user }}"
group: oinstall
recurse: true
when: asm_setup
- name: Ensure remote_tmp for oracle user exists with correct permissions
tags: pre, asm
ansible.builtin.file:
path: /home/oracle/.ansible/tmp
state: directory
mode: '700'
owner: "{{ grid_user }}"
group: oinstall
- name: Ensure required packages for install are present.
tags: pre, asm, install
ansible.builtin.package:
name: [ binutils, gcc, gcc-c++, glibc, glibc-devel, ksh, libgcc, libstdc++, libstdc++-devel, libaio, libXext, libXtst, libX11, libXau, libxcb, libXi, make, sysstat, elfutils-libelf-devel, libnsl ]
state: present
# - name: Get channel command word (ccw) value from lsdasd for use in next task.
# tags: asm
# ansible.builtin.shell: "lsdasd | grep {{ asm_disk_path.split('/')[-1] }} | awk '{print $1}'"
# register: ccw
# changed_when: false
# when: asm_disk_type == 'dasd' and asm_setup
- name: Template response file for silent GridSetup.sh
tags: asm
ansible.builtin.template:
src: grid_install.rsp.j2
dest: "{{ grid_home }}/install/response/grid_install.rsp"
owner: "{{ grid_user }}"
group: oinstall
mode: '700'
when: asm_setup
- name: Attempting to install Oracle Grid Infrastructure...
block:
- name: Install Oracle Grid Infrastructure using templated response file and apply release update.
tags: install, asm
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
set -o pipefail
source /home/{{ grid_user }}/.bash_profile
{{ grid_home }}/gridSetup.sh -silent -responseFile {{ grid_home }}/install/response/grid_install.rsp -applyRU {{ grid_ru }} -ignorePrereqFailure -waitforcompletion
register: grid_setup
failed_when: "'Successfully Setup Software' not in grid_setup.stdout"
when: asm_setup
rescue:
- name: gridSetup.sh failed!
tags: install, asm
fail:
msg: "ERROR: gridSetup.sh failed. Please see output for debugging purposes, take action to remediate errors, and re-run the playbook when ready."
when: asm_setup
always:
- name: Print results from gridSetup.sh
tags: install, asm
ansible.builtin.debug:
msg: "{{ grid_setup.stdout_lines }}"
when: asm_setup
- name: Run orainstRoot.sh script.
tags: install, asm, orainstroot, post
ansible.builtin.command: "{{ oracle_inventory }}/orainstRoot.sh"
when: asm_setup
# - name: Check if there are OHASD-related SELinux denials
# tags: install, asm, post, root, selinux
# ansible.builtin.shell: "grep ohasd /var/log/audit/audit.log"
# register: selinux_denials
# failed_when: false
# changed_when: false
# when: asm_setup
# - name: Create directory for SELinux policy for OHASD.
# tags: install, asm, post, root, selinux
# ansible.builtin.file:
# path: /etc/selinux/targeted/modules/active/modules
# state: directory
# mode: '755'
# when: asm_setup
# - name: Generate SELinux policy for OHASD
# tags: install, asm, post, root, selinux
# ansible.builtin.shell:
# args:
# chdir: /etc/selinux/targeted/modules/active/modules
# cmd: "audit2allow -M my_oracle"
# stdin: selinux_denials.stdout
# creates: /etc/selinux/targeted/modules/active/modules/my_oracle.pp
# register: policy_created
# when: selinux_denials.stdout != "" and asm_setup
# - name: Check if policy is already loaded
# tags: install, asm, post, root, selinux
# ansible.builtin.shell: semodule -l | grep my_oracle
# register: policy_loaded
# failed_when: false
# changed_when: false
# when: asm_setup
# - name: Install SELinux policy for OHASD
# tags: install, asm, post, root, selinux
# ansible.builtin.shell: semodule -i /etc/selinux/targeted/modules/active/modules/my_oracle.pp
# when: policy_created.changed and policy_loaded.stdout == "" and asm_setup
- name: Set SELinux to permissive.
tags: install, asm, post, root, selinux
ansible.posix.selinux:
policy: targeted
state: permissive
- name: Make SELinux permissive permanently
tags: install, asm, post, root, selinux
ansible.builtin.lineinfile:
path: /etc/selinux/config
regexp: '^SELINUX='
line: 'SELINUX=permissive'
- name: Attempting to run root.sh script...
block:
- name: Run root.sh script.
tags: install, asm, post, root
ansible.builtin.command: "{{ grid_home }}/root.sh"
register: root_exec
when: asm_setup
always:
- name: Print immediate output from root.sh script.
tags: install, asm, post, root
ansible.builtin.debug:
msg: "{{ root_exec.stdout_lines }}"
when: asm_setup
- name: Check root.sh script's logs.
tags: install, asm, post, root
ansible.builtin.shell: "find {{ grid_home }}/install -name 'root*.log' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2- | xargs cat"
register: root_log
changed_when: false
when: asm_setup
- name: Print logs from root.sh script.
tags: install, asm, post, root
ansible.builtin.debug:
msg: "{{ root_log.stdout_lines }}"
when: asm_setup
# - name: Set sysasm password.
# tags: install, asm, post, passwd, dg
# become: true
# become_user: "{{ grid_user }}"
# environment:
# ORACLE_HOME: "{{ oracle_home }}"
# ORACLE_SID: +ASM
# ansible.builtin.shell:
# cmd: "{{ grid_home }}/bin/orapwd file={{ oracle_home }}/dbs/orapw+ASM password='{{ grid_sys_pass }}' force=y"
# creates: "{{ oracle_home }}/dbs/orapw+ASM"
# when: asm_setup
- block:
- name: Finish gridSetup configuration.
tags: install, asm, post, config
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: "{{ grid_home }}/gridSetup.sh -silent -executeConfigTools -responseFile {{ grid_home }}/install/response/grid_install.rsp"
register: grid_config
when: asm_setup
rescue:
- block:
- name: Check for ASM Process Monitor.
tags: install, asm, post, validate
ansible.builtin.shell: "ps -ef | grep '[p]mon'"
register: pmon_check
changed_when: false
failed_when: "pmon_check.rc != 0"
when: asm_setup
rescue:
- name: Check if Oracle ASM is already added.
tags: install, asm, post, validate
ansible.builtin.shell: "{{ grid_home }}/bin/srvctl config asm"
register: asm_config
failed_when: false
changed_when: false
when: asm_setup
- name: Add Oracle ASM, if not already added.
tags: install, asm, post, validate
ansible.builtin.shell: "{{ grid_home }}/bin/srvctl add asm -p '+DATA'"
when: "'ASM is not configured' in asm_config.stdout or 'Resource ora.asm does not exist' in asm_config.stdout and asm_setup"
- name: Check ASM status
tags: install, asm, post, validate
ansible.builtin.command: "{{ grid_home }}/bin/srvctl status asm"
register: asm_status
failed_when: false
changed_when: false
when: asm_setup
- name: Start ASM
tags: install, asm, post, validate
ansible.builtin.command: "{{ grid_home }}/bin/srvctl start asm"
when: "'ASM is not running' in asm_status.stdout or 'Resource ora.asm does not exist' in asm_config.stdout and asm_setup"
- name: Check for ASM Process Monitor.
tags: install, asm, post, validate
ansible.builtin.shell: "ps -ef | grep '[p]mon'"
register: pmon_check
failed_when: "pmon_check.rc != 0"
when: asm_setup
always:
- name: Print output of checking for ASM Process Monitor task for debugging/verfification.
tags: install, asm, post, validate
ansible.builtin.debug:
msg: "{{ pmon_check.stdout }}"
when: asm_setup
- block:
- name: Check status of listener.
tags: install, asm, post, netca, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
source /home/{{ grid_user }}/.bash_profile
lsnrctl status
register: lsnrctl_status
failed_when: "'The command completed successfully' not in lsnrctl_status.stdout_lines"
when: asm_setup
rescue:
- name: Template out netca response file.
tags: install, asm, post, netca, validate
ansible.builtin.template:
src: netca.rsp.j2
dest: "/home/{{ grid_user }}/netca.rsp"
owner: "{{ grid_user }}"
group: oinstall
mode: '600'
when: asm_setup
- name: Configure netca with response file.
tags: install, asm, post, netca, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.command:
cmd: "{{ grid_home }}/bin/netca -silent -responsefile /home/{{ grid_user }}/netca.rsp"
creates: "{{ grid_home }}/network/admin/listener.ora"
when: asm_setup
- name: Check status of listener for debugging / verification.
tags: install, asm, post, netca, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
source /home/{{ grid_user }}/.bash_profile
lsnrctl status
register: lsnrctl_status
changed_when: false
failed_when: "'The command completed successfully' not in lsnrctl_status.stdout_lines"
when: asm_setup
always:
- name: Print listener status for debugging/verification.
tags: install, asm, post, netca, validate
ansible.builtin.debug:
msg: "{{ lsnrctl_status.stdout }}"
when: asm_setup
- block:
- name: Check status of cluster resources.
tags: install, asm, post, crsctl, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
source /home/{{ grid_user }}/.bash_profile
crsctl status res -t
register: crsctl_status
changed_when: false
when: asm_setup
- name: Print cluster resources status for debugging/verification.
tags: install, asm, post, crsctl, validate
ansible.builtin.debug:
msg: "{{ crsctl_status.stdout }}"
when: asm_setup
always:
- name: Check for ASM Process Monitor.
tags: install, asm, post, validate
ansible.builtin.shell: "ps -ef | grep '[p]mon'"
register: pmon_check
changed_when: false
failed_when: "pmon_check.rc != 0"
when: asm_setup and not grid_config.failed
- name: Print output of checking for ASM Process Monitor task for debugging/verfification.
tags: install, asm, post, validate
ansible.builtin.debug:
msg: "{{ pmon_check.stdout }}"
when: asm_setup and not grid_config.failed
- name: Check status of listener.
tags: install, asm, post, netca, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
source /home/{{ grid_user }}/.bash_profile
lsnrctl status
register: lsnrctl_status
failed_when: "'The command completed successfully' not in lsnrctl_status.stdout_lines"
when: asm_setup and not grid_config.failed
- name: Check status of cluster resources.
tags: install, asm, post, crsctl, validate
become: true
become_user: "{{ grid_user }}"
ansible.builtin.shell: |
source /home/{{ grid_user }}/.bash_profile
crsctl status res -t
register: crsctl_status
changed_when: false
when: asm_setup and not grid_config.failed
- name: Print cluster resources status for debugging/verification.
tags: install, asm, post, crsctl, validate
ansible.builtin.debug:
msg: "{{ crsctl_status.stdout }}"
when: asm_setup and not grid_config.failed
# - name: Template out TNSNAMES.ORA file.
# tags: install, asm, post, dg, tns
# ansible.builtin.template:
# src: TNSNAMES.ORA.j2
# dest: "{{ grid_home }}/network/admin/TNSNAMES.ORA"
# owner: "{{ grid_user }}"
# group: oinstall
# mode: '600'
# when: asm_setup
# - name: Get channel command word (ccw) value from lsdasd for use in next step.
# tags: always
# ansible.builtin.shell: "lsdasd | grep {{ asm_disk_path.split('/')[-1] }} | awk '{print $1}'"
# register: ccw
# changed_when: false
# when: asm_setup
# - name: Set ccw_num fact based on output from previous task.
# tags: always
# ansible.builtin.set_fact:
# ccw_num: "{{ ccw.stdout.split('.')[-1] }}"
# - name: Install required python3 modules.
# tags: install, asm, post, dg
# become: true
# become_user: "{{ grid_user }}"
# ansible.builtin.pip:
# name: "{{ item }}"
# state: latest
# executable: pip3
# extra_args: '--user'
# loop:
# - setuptools
# - cx_Oracle
# when: asm_setup
# - name: Create directory for Oracle Instant Client.
# tags: install, asm, post, dg
# ansible.builtin.file:
# path: /opt/oracle
# state: directory
# owner: "{{ oracle_user }}"
# group: oinstall
# mode: '775'
# when: asm_setup
# - name: Unzip Oracle Instant Client.
# tags: install, asm, post, dg
# ansible.builtin.unarchive:
# src: "{{ ora_inst_client }}"
# dest: /opt/oracle
# creates: "/opt/oracle/instantclient_*/libclntsh.so"
# remote_src: true
# owner: "{{ oracle_user }}"
# group: oinstall
# mode: '775'
# unsafe_writes: yes
# register: unzip_client
# when: asm_setup
# - name: Find path to Oracle Instant Client.
# tags: install, asm, post, dg, create
# ansible.builtin.shell: "find /opt/oracle -type d -name 'instantclient_*' -printf '%T@ %p\n' | sort -nr | head -n 1 | cut -f2- -d' '"
# changed_when: false
# register: instant_client_path
# when: asm_setup
# - name: Add LD_LIBRARY_PATH to root, grid and oracle users' bash_profiles.
# tags: install, asm, post, dg
# ansible.builtin.lineinfile:
# path: "{{ item.path }}"
# line: "export LD_LIBRARY_PATH={{ instant_client_path.stdout }}:$LD_LIBRARY_PATH"
# regexp: "LD_LIBRARY_PATH"
# create: true
# owner: "{{ item.owner }}"
# group: "{{ item.group }}"
# loop:
# - { path: "/home/{{ grid_user }}/.bash_profile", owner: "{{ grid_user }}", group: "{{ grid_user }}" }
# - { path: "/home/{{ oracle_user }}/.bash_profile", owner: "{{ oracle_user }}", group: "{{ oracle_user }}" }
# - { path: "/root/.bash_profile", owner: root, group: root }
# when: unzip_client.changed and asm_setup
# - name: Ensure Oracle Instant Client directory's permissions are set correctly.
# tags: install, asm, post, dg
# ansible.builtin.file:
# path: "{{ instant_client_path.stdout }}"
# owner: "{{ oracle_user }}"
# group: oinstall
# mode: '775'
# recurse: true
# when: asm_setup
# - name: Symlink libclntsh.so to grid home binary directory.
# tags: install, asm, post, dg
# ansible.builtin.file:
# src: "{{ instant_client_path.stdout }}/libclntsh.so"
# dest: "{{ grid_home }}/bin/libclntsh.so"
# state: link
# owner: "{{ grid_user }}"
# group: oinstall
# mode: '775'
# when: asm_setup
# - name: Set oracle instant client in ldconf.
# tags: install, asm, post, dg
# ansible.builtin.lineinfile:
# path: /etc/ld.so.conf.d/oracle-instantclient.conf
# line: "{{ instant_client_path.stdout }}"
# create: true
# when: asm_setup
# - name: Run ldconfig.
# tags: install, asm, post, dg
# ansible.builtin.command: "ldconfig"
# when: asm_setup
# - name: Ensure Oracle ASM disk group is properly created and attributes are set correctly.
# tags: install, asm, post, dg, create
# become: true
# become_user: "{{ grid_user }}"
# vars:
# ccw_num: "{{ asm_disk_ccw.split('.')[-1] }}"
# environment:
# PATH: "{{ instant_client_path.stdout }}:PATH"
# ORACLE_SID: +ASM
# ORAENV_ASK: NO
# ORACLE_HOME: "{{ grid_home }}"
# ORACLE_BASE: "{{ oracle_base }}"
# LD_LIBRARY_PATH: "{{ instant_client_path.stdout }}"
# TNS_ADMIN: "{{ grid_home }}/network/admin/TNSNAMES.ORA"
# oracle_asmdg:
# name: data
# disks: "/dev/oracleasm/asm{{ ccw_num }}"
# attribute_name: compatible.asm
# attribute_value: "{{ oracle_version.split('.')[0,1] }}"
# redundancy: external
# state: present
# #username: sysasm
# #password: "{{ grid_sys_pass }}"
# service_name: '+ASM'
# host: "{{ ansible_hostname }}"
# oracle_home: "{{ grid_home }}"
# when: asm_setup
handlers:
- import_tasks: handlers/main.yaml