|
5 | 5 | msg: "Managing patches for {{ oracle_home_db }}" |
6 | 6 | when: apply_patches_db |
7 | 7 |
|
8 | | -- name: Transfer files |
9 | | - ansible.builtin.include_tasks: transfer-files.yml |
10 | | - when: oracle_sw_copy |
11 | | - |
12 | | -- name: Unpack uploaded files |
13 | | - ansible.builtin.include_tasks: unpack-files.yml |
14 | | - when: oracle_sw_unpack and apply_patches_db |
15 | | - |
16 | 8 | - name: Upgrade OPatch |
17 | 9 | ansible.builtin.include_tasks: opatch-upgrade.yml |
18 | | - when: apply_patches_db |
19 | 10 |
|
20 | | -- name: db_opatch | Configure ocm.rsp (1) |
| 11 | +- name: Get list of current installed patches |
| 12 | + ansible.builtin.command: "{{ oracle_home_db }}/OPatch/opatch lspatches -oh {{ oracle_home_db }}" |
| 13 | + become: true |
| 14 | + become_user: "{{ oracle_user }}" |
| 15 | + changed_when: false |
| 16 | + register: dbhome_patches |
| 17 | + |
| 18 | +- name: List of current installed patches |
| 19 | + ansible.builtin.debug: |
| 20 | + var: dbhome_patches.stdout_lines |
| 21 | + |
| 22 | +- name: Configure ocm.rsp (1) |
21 | 23 | ansible.builtin.template: |
22 | 24 | src: ocmrsp.expect.j2 |
23 | 25 | dest: "={{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect" |
24 | | - mode: "0777" |
| 26 | + mode: "0644" |
25 | 27 | force: true |
26 | 28 | when: |
27 | 29 | - apply_patches_db |
|
31 | 33 | tags: |
32 | 34 | - ocmconfig |
33 | 35 |
|
34 | | -- name: db_opatch | Configure ocm.rsp (2) |
35 | | - ansible.builtin.shell: "{{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect" |
36 | | - # noqa command-instead-of-shell |
| 36 | +- name: Configure ocm.rsp (2) |
| 37 | + ansible.builtin.command: "{{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect" |
37 | 38 | when: |
38 | 39 | - apply_patches_db |
39 | 40 | - current_opatch_version.msg is version_compare('12.2.0.1.5', '<') |
|
43 | 44 | tags: |
44 | 45 | - ocmconfig |
45 | 46 |
|
46 | | -- name: db_opatch | Remove unwanted patches from DB |
| 47 | +- name: Remove unwanted patches from DB |
47 | 48 | opitzconsulting.ansible_oracle.oracle_opatch: |
48 | 49 | oracle_home: "{{ oracle_home_db }}" |
49 | 50 | patch_base: "{{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default(item.patchid) }}/" |
|
65 | 66 | when: |
66 | 67 | - apply_patches_db | bool |
67 | 68 | - db_homes_config[dbh.home]['opatch'] is defined |
| 69 | + - dbhome_patches.stdout_lines | select('match', item.patchid | string) | length > 0 |
68 | 70 | register: psuapplym |
69 | 71 |
|
70 | | -- name: db_opatch | Manage opatchauto patches for DB (non-gi) |
| 72 | +- name: Manage opatchauto patches for DB (non-gi) |
71 | 73 | opitzconsulting.ansible_oracle.oracle_opatch: |
72 | 74 | oracle_home: "{{ oracle_home_db }}" |
73 | 75 | patch_base: "{{ oracle_patch_install }}/{{ db_version }}/{{ item.0.path | default (item.0.patchid) }}/{{ item.1 }}" |
|
95 | 97 | - not olrloc.stat.exists |
96 | 98 | register: psuapplym |
97 | 99 |
|
98 | | -- name: db_opatch | Manage opatchauto patches for DB (gi) |
99 | | - opitzconsulting.ansible_oracle.oracle_opatch: |
100 | | - oracle_home: "{{ oracle_home_db }}" |
101 | | - patch_base: "{{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default(item.patchid) }}/" |
102 | | - patch_id: "{{ item.patchid }}" |
103 | | - patch_version: "{{ item.patchversion | default(omit) }}" |
104 | | - opatchauto: true |
105 | | - conflict_check: true |
106 | | - ocm_response_file: "{{ ocm_response_file | default(omit) }}" |
107 | | - output: verbose |
108 | | - state: "{{ item.state }}" |
| 100 | +- name: Manage Patch from db_home_config with opatchauto |
| 101 | + ansible.builtin.include_tasks: loop_patchid.yml |
109 | 102 | with_items: |
110 | 103 | - "{{ db_homes_config[dbh.home]['opatchauto'] }}" |
111 | | - # run_once: "{{ _oraswgi_meta_configure_cluster}}" |
112 | | - become: true |
113 | | - tags: |
114 | | - - apply_patch_db |
| 104 | + loop_control: |
| 105 | + loop_var: dhc_opatch |
| 106 | + label: >- |
| 107 | + home: {{ dbh.home | default('') }} |
| 108 | + patchid: {{ dhc_opatch.patchid | default('') }} |
| 109 | + state: {{ dhc_opatch.state | default('') }} |
| 110 | + excludeUPI: {{ dhc_opatch.excludeUPI | default('') }} |
115 | 111 | when: |
116 | | - - apply_patches_db and db_homes_config[dbh.home]['opatchauto'] is defined |
117 | | - - olrloc.stat.exists |
118 | | - register: psuapplym |
| 112 | + - db_homes_config[dbh.home]['opatchauto'] is defined |
| 113 | + - dhc_opatch.state | default('') == 'present' |
| 114 | + vars: |
| 115 | + __opatchauto_patchtype: true # opatch opatchauto |
119 | 116 |
|
120 | | -# Do not try to revert patches here |
121 | | -# => That was done with a previous task! |
122 | | -- name: db_opatch | Manage patches for DB |
123 | | - opitzconsulting.ansible_oracle.oracle_opatch: |
124 | | - oracle_home: "{{ oracle_home_db }}" |
125 | | - patch_base: "{{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default(item.patchid) }}/" |
126 | | - patch_id: "{{ item.patchid }}" |
127 | | - patch_version: "{{ item.patchversion | default(omit) }}" |
128 | | - exclude_upi: "{{ item.excludeUPI | default(omit) }}" |
129 | | - opatchauto: false |
130 | | - conflict_check: true |
131 | | - stop_processes: "{{ item.stop_processes | default(False) }}" |
132 | | - ocm_response_file: "{{ ocm_response_file | default(omit) }}" |
133 | | - output: verbose |
134 | | - state: "{{ item.state }}" |
| 117 | +# manage-patch does everything for 1 patch in a loop |
| 118 | +- name: Manage Patch from db_home_config with opatch |
| 119 | + ansible.builtin.include_tasks: loop_patchid.yml |
135 | 120 | with_items: |
136 | | - - "{{ db_homes_config[dbh.home]['opatch'] | selectattr('state', 'match', 'present') }}" |
137 | | - # run_once: "{{ _oraswgi_meta_configure_cluster }}" |
138 | | - become: true |
139 | | - become_user: "{{ oracle_user }}" |
140 | | - tags: |
141 | | - - apply_patch_db |
| 121 | + - "{{ db_homes_config[dbh.home]['opatch'] }}" |
| 122 | + loop_control: |
| 123 | + loop_var: dhc_opatch |
| 124 | + label: >- |
| 125 | + home: {{ dbh.home | default('') }} |
| 126 | + patchid: {{ dhc_opatch.patchid | default('') }} |
| 127 | + state: {{ dhc_opatch.state | default('') }} |
| 128 | + excludeUPI: {{ dhc_opatch.excludeUPI | default('') }} |
142 | 129 | when: |
143 | | - - apply_patches_db |
144 | 130 | - db_homes_config[dbh.home]['opatch'] is defined |
145 | | - register: psuapplym |
| 131 | + - dhc_opatch.state | default('') == 'present' |
| 132 | + vars: |
| 133 | + __opatchauto_patchtype: false # opatch apply |
146 | 134 |
|
147 | | -- name: db_opatch | Check patches |
148 | | - ansible.builtin.shell: "{{ oracle_home_db }}/OPatch/opatch lspatches -oh {{ oracle_home_db }}" |
149 | | - # noqa command-instead-of-shell |
| 135 | +- name: Check patches |
| 136 | + ansible.builtin.command: "{{ oracle_home_db }}/OPatch/opatch lspatches -oh {{ oracle_home_db }}" |
150 | 137 | become: true |
151 | 138 | become_user: "{{ oracle_user }}" |
152 | 139 | changed_when: false |
153 | 140 | register: dbhome_patches |
154 | 141 |
|
155 | | -- name: db_opatch | Check patches |
| 142 | +- name: Check patches |
156 | 143 | ansible.builtin.debug: |
157 | 144 | var: dbhome_patches.stdout_lines |
0 commit comments