Skip to content

Commit 376b324

Browse files
committed
oraswgi_manage_patches
1 parent 8ec3336 commit 376b324

File tree

9 files changed

+382
-114
lines changed

9 files changed

+382
-114
lines changed

roles/oraswgi_install/tasks/19.3.0.0.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
when:
3333
- _orasw_meta_primary_node | bool
3434

35+
# IMPORTANT!
36+
# Copy patches to 1st node only, when -applyRU is used.
3537
- name: include 19c/21c | Copy Patches for -applyRU when version >=19c
3638
ansible.builtin.import_role:
3739
name: oraswgi_manage_patches

roles/oraswgi_manage_patches/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Install/Remove Patches from Oracle Database Homes
66

77
- [Requirements](#requirements)
88
- [Discovered Tags](#discovered-tags)
9+
- [Open Tasks](#open-tasks)
910
- [Dependencies](#dependencies)
1011
- [License](#license)
1112
- [Author](#author)
@@ -21,10 +22,13 @@ Install/Remove Patches from Oracle Database Homes
2122

2223
**_always_**
2324

25+
**_assert_**
26+
2427
**_current_opatch_version_**
2528

26-
**_oragridpatchunpack_**
29+
## Open Tasks
2730

31+
- (information): support for www download missing
2832

2933
## Dependencies
3034

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
- name: Work on Patch {{ gip_opatch.0.patchid }}
2+
# loop_var: gip_opatch
3+
#
4+
- name: loop_patchid | Work on Patch {{ gip_opatch.0.patchid }}
35
ansible.builtin.debug:
46
msg:
57
- >-
@@ -12,7 +14,7 @@
1214
- >-
1315
patchsubdir: {{ __oraswdb_manage_patches_patchsubdir | default('') }}
1416
15-
- name: Work on oracle_sw_patches
17+
- name: loop_patchid | Work on oracle_sw_patches
1618
ansible.builtin.include_tasks: loop_stage_patch.yml
1719
vars:
1820
__sw_patches_filename_creates: "{{ osp_loop.creates | default((gip_opatch.0.patchid | string) + '/README.txt') }}"
@@ -21,31 +23,29 @@
2123
{%- if osp_loop.unique_patchid is defined -%}
2224
upi_{{ osp_loop.unique_patchid -}}/{% endif -%}
2325
with_items:
24-
- "{{ oracle_sw_patches | selectattr('patchid', 'equalto', gip_opatch.0.patchid) }}"
26+
- "{{ oracle_sw_patches | selectattr('patchid', 'equalto', gip_opatch.0.patchid) | list }}"
2527
loop_control:
2628
loop_var: osp_loop
2729
label: >-
2830
patchid: {{ osp_loop.patchid }}
2931
filename: {{ osp_loop.filename }}
3032
unique_patchid: {{ osp_loop.unique_patchid | default('') }}
3133
when:
32-
- apply_patches_db
34+
- apply_patches_db | bool
3335
- gip_opatch.0.state == 'present'
3436
- not gihome_patches.stdout_lines | select('match', osp_loop.patchid | string) | length > 0
3537
# - osp_loop.unique_patchid | default(0) == gip_opatch.excludeUPI | default(0)
3638

37-
38-
- name: Info
39+
- name: loop_patchid | Info
3940
ansible.builtin.debug:
4041
msg: Starting opatch apply. This could take some time to complete...
4142

4243
# opatchauto needs root user for execution
43-
- name: Manage patch with opatch (opatchauto / apply)
44+
- name: loop_patchid | Manage patch with opatch (opatchauto / apply)
4445
opitzconsulting.ansible_oracle.oracle_opatch:
4546
oracle_home: "{{ oracle_home_gi }}"
46-
patch_base: |-
47-
{{ oracle_patch_install }}/{{ oracle_install_version_gi }}/
48-
{{- gip_opatch.0.path | default(__patch_upisubdir + (gip_opatch.0.patchid | string)) }}/
47+
patch_base: >-
48+
{{ oracle_patch_install }}/{{ oracle_install_version_gi }}/{{ dhc_opatch.path | default(__patch_base_local) }}
4949
patch_id: "{{ gip_opatch.0.patchid }}"
5050
patch_version: "{{ gip_opatch.0.patchversion | default(omit) }}"
5151
exclude_upi: "{{ gip_opatch.0.excludeUPI | default(omit) }}"
@@ -59,8 +59,7 @@
5959
become: true
6060
become_user: "{{ __opatchauto_patchtype | ternary('root', grid_user) }}"
6161
vars:
62-
__patch_upisubdir: >-
63-
{%- if gip_opatch.0.excludeUPI is defined -%}
64-
upi_{{ gip_opatch.0.excludeUPI -}}/{% endif -%}
62+
__patch_base_local: |-
63+
{{ gip_opatch.0.excludeUPI | default(gip_opatch.0.patchid) }}/{{ gip_opatch.0.patchid | string }}/{{ gip_opatch.1 | string }}
6564
when:
6665
- __execute_opatch | bool

roles/oraswgi_manage_patches/tasks/loop_stage_patch.yml

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,39 @@
2020
- name: Loop_stage_patch | Become User to oracle
2121
become: true
2222
become_user: "{{ _grid_install_user }}"
23+
vars:
24+
_oraswgi_manage_patches_sw_patch_dict: "{{ osp_loop }}"
25+
_oraswgi_manage_patches_unique_patchid: >-
26+
{{ _oraswgi_manage_patches_sw_patch_dict.unique_patchid | default(_oraswgi_manage_patches_sw_patch_dict.patchid) }}
27+
_oraswgi_manage_patches_unarchive_dir: "{{ oracle_patch_stage }}/{{ _oraswgi_manage_patches_sw_patch_dict.version }}/{{ _oraswgi_manage_patches_unique_patchid }}"
28+
_oraswgi_manage_patches_creates: >-
29+
{{ _oraswgi_manage_patches_unarchive_dir }}/{{ _oraswgi_manage_patches_sw_patch_dict.creates | default((_oraswgi_manage_patches_sw_patch_dict.patchid | string) + '/README.txt') }}
30+
2331
block:
24-
- name: Loop_stage_patch | Copy oracle DB patch (opatch) to server
32+
- name: Loop_stage_patch | State data for loop_stage_patch.yml
33+
ansible.builtin.debug:
34+
msg:
35+
- >-
36+
patchid: {{ _oraswgi_manage_patches_sw_patch_dict['patchid'] | default('') }}
37+
unique_patchid: {{ _oraswgi_manage_patches_unique_patchid | default('') }}
38+
- >-
39+
oracle_patch_stage: {{ oracle_patch_stage }}
40+
is_sw_source_local: {{ is_sw_source_local | bool }}
41+
- >-
42+
creates: {{ _oraswgi_manage_patches_creates }}
43+
patch_unarchive_dir: {{ _oraswgi_manage_patches_unarchive_dir }}
44+
45+
- name: Loop_stage_patch | Check for unarchived patch archive
46+
ansible.builtin.stat:
47+
path: "{{ _oraswgi_manage_patches_creates }}"
48+
register: checkpatcharchiveres
49+
50+
- name: Loop_stage_patch | Copy oracle GI/Restart patch to server (local)
51+
ansible.builtin.copy:
52+
src: "{{ oracle_sw_source_local }}/{{ _oraswgi_manage_patches_sw_patch_dict.filename }}"
53+
dest: "{{ oracle_stage }}/{{ _oraswgi_manage_patches_sw_patch_dict.filename }}"
54+
mode: "0644"
55+
force: false
2556
when:
2657
- oracle_sw_copy | bool
2758
- osp_loop.state == 'present'
@@ -64,20 +95,29 @@
6495
block:
6596
- name: Loop_stage_patch | Create destination folder for unarchive
6697
ansible.builtin.file:
67-
dest: "{{ __patch_unarchive_dir }}"
68-
mode: 0755
98+
dest: "{{ _oraswgi_manage_patches_unarchive_dir }}"
99+
mode: 0775
69100
state: directory
101+
owner: "{{ _grid_install_user }}"
102+
group: "{{ oracle_group }}"
103+
become: true
104+
become_user: root
70105

71106
- name: Loop_stage_patch | Extract one-off patch files to patch base
72107
ansible.builtin.unarchive:
73-
src: "{{ oracle_stage }}/{{ osp_loop.filename }}"
74-
dest: "{{ __patch_unarchive_dir }}"
75-
creates: "{{ __patch_unarchive_dir }}/{{ __sw_patches_filename_creates }}"
108+
src: "{{ oracle_stage }}/{{ _oraswgi_manage_patches_sw_patch_dict.filename }}"
109+
dest: "{{ _oraswgi_manage_patches_unarchive_dir }}"
110+
creates: "{{ _oraswgi_manage_patches_creates }}"
76111
copy: false
112+
owner: "{{ _grid_install_user }}"
113+
group: "{{ oracle_group }}"
114+
mode: o+r,g+r
115+
become: true
116+
become_user: root
77117

78118
- name: Loop_stage_patch | Remove patch archive from stage
79119
ansible.builtin.file:
80-
path: "{{ oracle_stage }}/{{ osp_loop.filename }}"
120+
path: "{{ oracle_stage }}/{{ _oraswgi_manage_patches_sw_patch_dict.filename }}"
81121
state: absent
82122
when:
83123
- oracle_sw_copy | bool

0 commit comments

Comments
 (0)