Skip to content

Commit

Permalink
oraswdb_manage_patches: added parameter oraswdb_manage_patches_force_…
Browse files Browse the repository at this point in the history
…opatch_upgrade for applyRU in runInstaller
  • Loading branch information
Rendanic committed Sep 1, 2024
1 parent 3bf6519 commit 4efbb70
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 15 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/oraswdb_manage_patches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "oraswdb_manage_patches: added parameter oraswdb_manage_patches_force_opatch_upgrade for applyRU in runInstaller (oravirt#469)"
16 changes: 14 additions & 2 deletions roles/oraswdb_manage_patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Manage Patch Installation in Database ORACLE_HOMEs.
- [Requirements](#requirements)
- [Default Variables](#default-variables)
- [oraswdb_manage_patches_cleanup_staging](#oraswdb_manage_patches_cleanup_staging)
- [oraswdb_manage_patches_force_opatch_upgrade](#oraswdb_manage_patches_force_opatch_upgrade)
- [Discovered Tags](#discovered-tags)
- [Dependencies](#dependencies)
- [License](#license)
Expand All @@ -32,6 +33,19 @@ Remove following list of directories after DB-Patching when `oracle_sw_copy: tru
oraswdb_manage_patches_cleanup_staging: true
```
### oraswdb_manage_patches_force_opatch_upgrade
Upgrade OPatch without checking for existing version.
Needed for prepatch installations, because Home is not
registered in central inventory.
#### Default value
```YAML
oraswdb_manage_patches_force_opatch_upgrade: false
```
## Discovered Tags
**_always_**
Expand All @@ -40,8 +54,6 @@ oraswdb_manage_patches_cleanup_staging: true
**_autopatch_**
**_current_opatch_version_**
**_directories_**
**_molecule-idempotence-notest_**
Expand Down
8 changes: 8 additions & 0 deletions roles/oraswdb_manage_patches/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
# - "{{ oracle_stage }}/patches"
# @end
oraswdb_manage_patches_cleanup_staging: true

# @var oraswdb_manage_patches_force_opatch_upgrade:description: >
# Upgrade OPatch without checking for existing version.
#
# Needed for prepatch installations, because Home is not
# registered in central inventory.
# @end
oraswdb_manage_patches_force_opatch_upgrade: false
32 changes: 32 additions & 0 deletions roles/oraswdb_manage_patches/tasks/copy_patches_for_dbh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# copy Patches to target server for oracle_homes_installed
# Used in oraswdb_install for copy patches to prepatch runInstaller with -applyRU

# dhc_opatch is needed as an input for this task-file!
- name: copy_patches_for_dbh | Assert
ansible.builtin.assert:
quiet: true
that:
- dhc_opatch is defined

- name: copy_patches_for_dbh | Work on oracle_sw_patches
ansible.builtin.include_tasks: loop_opatch_apply.yml
vars:
__sw_patches_filename_creates: "{{ osp_loop.creates | default((dhc_opatch.patchid | string) + '/README.txt') }}"
__patch_unarchive_dir: "{{ oracle_patch_stage }}/{{ db_version }}/{{ __patch_upisubdir }}/"
__patch_upisubdir: >-
{{ osp_loop.unique_patchid is defined
| ternary(osp_loop.unique_patchid,
osp_loop.patchid) }}/
with_items:
- "{{ oracle_sw_patches | selectattr('patchid', 'equalto', dhc_opatch.patchid) }}"
loop_control:
loop_var: osp_loop
label: >-
patchid: {{ osp_loop.patchid }}
filename: {{ osp_loop.filename }}
unique_patchid: {{ osp_loop.unique_patchid | default('') }}
when:
- apply_patches_db
- dhc_opatch.state == 'present'
- osp_loop.unique_patchid | default(0) == dhc_opatch.excludeUPI | default(0)
36 changes: 23 additions & 13 deletions roles/oraswdb_manage_patches/tasks/opatch-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
---
# We need the following block for prepatch installations of ORACLE_HOMEs
# because the home is not registered in central Inventtory and the check
# for getting current version of OPatch will fail.
- name: db_opatch | Check current opatch version
opitzconsulting.ansible_oracle.oracle_opatch:
oracle_home: "{{ oracle_home_db }}"
state: opatchversion
register: current_opatch_version
tags: current_opatch_version
when: db_homes_config[dbh.home]['opatch_minversion'] is defined
when: not oraswdb_manage_patches_force_opatch_upgrade | bool
block:
- name: db_opatch | Check current opatch version
opitzconsulting.ansible_oracle.oracle_opatch:
oracle_home: "{{ oracle_home_db }}"
state: opatchversion
register: current_opatch_version
tags: current_opatch_version
when: db_homes_config[dbh.home]['opatch_minversion'] is defined

- name: Output
ansible.builtin.debug: # noqa: no-handler
var: current_opatch_version.msg
tags: current_opatch_version
when: current_opatch_version.changed
- name: Output
ansible.builtin.debug: # noqa: no-handler
var: current_opatch_version.msg
tags: current_opatch_version
when: current_opatch_version.changed

- name: db_opatch | Upgrade Opatch block
when:
- apply_patches_db
- db_homes_config[dbh.home]['opatch_minversion'] is defined
- (current_opatch_version.msg is version_compare(db_homes_config[dbh.home]['opatch_minversion'], '<'))
- (current_opatch_version.msg | default('0')) is version_compare(db_homes_config[dbh.home]['opatch_minversion'], '<')
or
oraswdb_manage_patches_force_opatch_upgrade
block:
- name: db_opatch | Copy oracle opatch to server (www)
ansible.builtin.get_url:
Expand Down Expand Up @@ -102,7 +110,9 @@
- oragridpatchunpack

- name: db_opatch | Check current opatch version 2
when: db_homes_config[dbh.home]['opatch_minversion'] is defined
when:
- db_homes_config[dbh.home]['opatch_minversion'] is defined
- not oraswdb_manage_patches_force_opatch_upgrade
block:
- name: db_opatch | Check current opatch version 2
opitzconsulting.ansible_oracle.oracle_opatch:
Expand Down

0 comments on commit 4efbb70

Please sign in to comment.