Skip to content

Commit

Permalink
oraswdb-manage-patches: oracle-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Rendanic committed Sep 13, 2021
1 parent adc7b73 commit 964ce99
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 417 deletions.
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ exclude_paths:
- roles/oradb-delete

# ansible-oracle roles wip - will be removed after refactoring
- roles/oraswdb-manage-patches
- roles/oraswgi-install
- roles/oraswgi-manage-patches
- roles/oraswgi-opatch
1 change: 1 addition & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ jobs:
roles/oraswdb-golden-image
roles/oraswgi-golden-image
roles/oraswdb-install
roles/oraswdb-manage-patches
args: ""
104 changes: 61 additions & 43 deletions roles/oraswdb-manage-patches/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
---

#master_node: true
role_separation: false
hostgroup: "{{ group_names[0] }}"
cluster_master: "{{play_hosts[0]}}"
configure_cluster: false
# master_node: true
role_separation: false
hostgroup: "{{ group_names[0] }}"
cluster_master: "{{play_hosts[0]}}"
configure_cluster: false

oracle_user: oracle # User that will own the Oracle Installations.
oracle_group: oinstall # Primary group for oracle_user.
oracle_user: oracle # User that will own the Oracle Installations.
oracle_group: oinstall # Primary group for oracle_user.

oracle_sw_source_www: http://www/orasw # address to all software if using the get_url module when putting software on the host(s)
oracle_sw_source_local: /tmp # Path to all software if using the copy module when putting software on the host(s)
is_sw_source_local: true
install_from_nfs: false
oracle_sw_copy: "{% if install_from_nfs %}False{% else %}True{% endif %}"
oracle_sw_unpack: "{% if install_from_nfs %}False{% else %}True{% endif %}"
nfs_server_sw: nfsserver
nfs_server_sw_path: /path/to/orasw
oracle_sw_source_www: http://www/orasw # address to all software if using the get_url module when putting software on the host(s)
oracle_sw_source_local: /tmp # Path to all software if using the copy module when putting software on the host(s)
is_sw_source_local: true
install_from_nfs: false
oracle_sw_copy: "{% if install_from_nfs %}False{% else %}True{% endif %}"
oracle_sw_unpack: "{% if install_from_nfs %}False{% else %}True{% endif %}"
nfs_server_sw: nfsserver
nfs_server_sw_path: /path/to/orasw

oracle_stage: /u01/stage
oracle_stage_remote: "{{ oracle_stage }}"
oracle_stage_install: "{% if not oracle_sw_copy and not oracle_sw_unpack%}{{ oracle_stage_remote }}{% else %}{{ oracle_stage }}{% endif %}"
oracle_base: /u01/app/oracle
oracle_rsp_stage: "{{ oracle_stage }}/rsp"
oracle_patch_stage: "{{ oracle_stage }}/patches"
oracle_patch_stage_remote: "{{ oracle_stage_remote }}/patches"
oracle_patch_install: "{% if not oracle_sw_copy and not oracle_sw_unpack%}{{ oracle_patch_stage_remote }}{% else %}{{ oracle_patch_stage }}{% endif %}"
oracle_inventory_loc: /u01/app/oraInventory
ocm_response_file: "{{ oracle_patch_stage }}/{{ db_version }}/ocm.rsp"
oracle_stage: /u01/stage
oracle_stage_remote: "{{ oracle_stage }}"
oracle_stage_install: "{% if not oracle_sw_copy and not oracle_sw_unpack%}{{ oracle_stage_remote }}{% else %}{{ oracle_stage }}{% endif %}"
oracle_base: /u01/app/oracle
oracle_rsp_stage: "{{ oracle_stage }}/rsp"
oracle_patch_stage: "{{ oracle_stage }}/patches"
oracle_patch_stage_remote: "{{ oracle_stage_remote }}/patches"
oracle_patch_install: "{% if not oracle_sw_copy and not oracle_sw_unpack%}{{ oracle_patch_stage_remote }}{% else %}{{ oracle_patch_stage }}{% endif %}"
oracle_inventory_loc: /u01/app/oraInventory
ocm_response_file: "{{ oracle_patch_stage }}/{{ db_version }}/ocm.rsp"

apply_patches_db: False

# oracle_sw_patches: # Files containing the installation media for Grid Infrastructure
# - { filename: p27468969_122010_Linux-x86-64.zip, patchid: 27468969, version: 12.2.0.1, patchversion: 12.2.0.1.180417, description: GI-RU-April-2018, creates: 27468969/27674384/README.txt }
# - { filename: p27967747_121020_Linux-x86-64.zip, patchid: 27967747, version: 12.1.0.2, patchversion: 12.1.0.2.180717, description: GI-PSU-Jul-2018, creates: 27967747/27762277/etc/xml/ShiphomeDirectoryStructure.xml }
# - { filename: p27468957_121020_Linux-x86-64.zip, patchid: 27468957, version: 12.1.0.2, patchversion: 12.1.0.2.180417, description: GI-PSU-Apr-2018, creates: 27468957/27338013/etc/config/inventory.xml }
# - { filename: p19392646_121020_Linux-x86-64.zip, patchid: 19392646, version: 12.1.0.2, patchversion: 12.1.0.2.1, description: GI-PSU-Oct-2014 }
# - { filename: p20485724_121020_Linux-x86-64.zip, patchid: 20485724, version: 12.1.0.2, patchversion: 12.1.0.2.3, description: GI-PSU-Apr-2015 }
# - { filename: p21523234_121020_Linux-x86-64.zip, patchid: 21523234, version: 12.1.0.2, patchversion: 12.1.0.2.5, description: GI-PSU-Oct-2015 }
# - { filename: p24412235_121020_Linux-x86-64.zip, patchid: 24412235, version: 12.1.0.2, patchversion: 12.1.0.2.161018, description: GI-PSU-Oct-2016 }
# - { filename: p24968615_121020_Linux-x86-64.zip, patchid: 24968615, version: 12.1.0.2, patchversion: 12.1.0.2.170117, description: GI-PSU-Jan-2017}
# - { filename: p25434003_121020_Linux-x86-64.zip, patchid: 25434003, version: 12.1.0.2, patchversion: 12.1.0.2.170418, description: GI-PSU-Apr-2017}
# - { filename: p27475913_112040_Linux-x86-64.zip, patchid: 27475913, version: 11.2.0.4, patchversion: 11.2.0.4.180417, description: GI-PSU-Apr-2018, creates: 27475913/22502505/files/lib/acfstoolsdriver.sh }
# #- { filename: p25078431_11204160419forACFS_Linux-x86-64.zip, patchid: 25078431, version: 11.2.0.4, patchversion: 11.2.0.4.160419, description: '11.2.0.4.160419 for ACFS' }
# - { filename: p19380115_112040_Linux-x86-64.zip, patchid: 19380115, version: 11.2.0.4, patchversion: 11.2.0.4.4, description: GI-PSU-Apr-2018 }
# - { filename: p19380115_112040_Linux-x86-64.zip, patchid: 19380115, version: 11.2.0.4, patchversion: 11.2.0.4.4, description: GI-PSU-Oct-2014 }
# - { filename: p20485808_112040_Linux-x86-64.zip, patchid: 20485808, version: 11.2.0.4, patchversion: 11.2.0.4.6, description: GI-PSU-Apr-2015 }
# - { filename: p21523375_112040_Linux-x86-64.zip, patchid: 21523375, version: 11.2.0.4, patchversion: 11.2.0.4.8, description: GI-PSU-Oct-2015 }
apply_patches_db: false

# oracle_sw_patches: # Files containing the installation media for Grid Infrastructure
# - filename: p27468969_122010_Linux-x86-64.zip
# patchid: 27468969
# version: 12.2.0.1
# patchversion: 12.2.0.1.180417
# description: GI-RU-April-2018
# creates: 27468969/27674384/README.txt
# - filename: p27967747_121020_Linux-x86-64.zip
# patchid: 27967747
# version: 12.1.0.2
# patchversion: 12.1.0.2.180717
# description: GI-PSU-Jul-2018
# creates: 27967747/27762277/etc/xml/ShiphomeDirectoryStructure.xml
# - filename: p27468957_121020_Linux-x86-64.zip
# patchid: 27468957
# version: 12.1.0.2
# patchversion: 12.1.0.2.180417
# description: GI-PSU-Apr-2018
# creates: 27468957/27338013/etc/config/inventory.xml
# - { filename: p19392646_121020_Linux-x86-64.zip, patchid: 19392646, version: 12.1.0.2, patchversion: 12.1.0.2.1, description: GI-PSU-Oct-2014 }
# - { filename: p20485724_121020_Linux-x86-64.zip, patchid: 20485724, version: 12.1.0.2, patchversion: 12.1.0.2.3, description: GI-PSU-Apr-2015 }
# - { filename: p21523234_121020_Linux-x86-64.zip, patchid: 21523234, version: 12.1.0.2, patchversion: 12.1.0.2.5, description: GI-PSU-Oct-2015 }
# - { filename: p24412235_121020_Linux-x86-64.zip, patchid: 24412235, version: 12.1.0.2, patchversion: 12.1.0.2.161018, description: GI-PSU-Oct-2016 }
# - { filename: p24968615_121020_Linux-x86-64.zip, patchid: 24968615, version: 12.1.0.2, patchversion: 12.1.0.2.170117, description: GI-PSU-Jan-2017}
# - { filename: p25434003_121020_Linux-x86-64.zip, patchid: 25434003, version: 12.1.0.2, patchversion: 12.1.0.2.170418, description: GI-PSU-Apr-2017}
# - filename: p27475913_112040_Linux-x86-64.zip
# patchid: 27475913, version: 11.2.0.4
# patchversion: 11.2.0.4.180417
# description: GI-PSU-Apr-2018
# creates: 27475913/22502505/files/lib/acfstoolsdriver.sh
# - { filename: p19380115_112040_Linux-x86-64.zip, patchid: 19380115, version: 11.2.0.4, patchversion: 11.2.0.4.4, description: GI-PSU-Apr-2018 }
# - { filename: p19380115_112040_Linux-x86-64.zip, patchid: 19380115, version: 11.2.0.4, patchversion: 11.2.0.4.4, description: GI-PSU-Oct-2014 }
# - { filename: p20485808_112040_Linux-x86-64.zip, patchid: 20485808, version: 11.2.0.4, patchversion: 11.2.0.4.6, description: GI-PSU-Apr-2015 }
# - { filename: p21523375_112040_Linux-x86-64.zip, patchid: 21523375, version: 11.2.0.4, patchversion: 11.2.0.4.8, description: GI-PSU-Oct-2015 }
3 changes: 2 additions & 1 deletion roles/oraswdb-manage-patches/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
dependencies:
- { role: orasw-meta }
- role: orasw-meta
146 changes: 75 additions & 71 deletions roles/oraswdb-manage-patches/tasks/db-home-patch.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
- set_fact:
oracle_home_db: "{%- if db_homes_config[dbh.home]['oracle_home'] is defined -%}
{{db_homes_config[dbh.home]['oracle_home']}}
{%- else -%}
{{oracle_base}}/{{db_homes_config[dbh.home]['version']}}/{{db_homes_config[dbh.home]['home']}}
{%- endif -%}"
---
- set_fact: # noqa unnamed-task
oracle_home_db: "{%- if db_homes_config[dbh.home]['oracle_home'] is defined -%}
{{ db_homes_config[dbh.home]['oracle_home'] }}
{%- else -%}
{{ oracle_base }}/{{ db_homes_config[dbh.home]['version'] }}/{{ db_homes_config[dbh.home]['home'] }}
{%- endif -%}"

- debug: msg="Managing patches for {{ oracle_home_db}}"
- debug: msg="Managing patches for {{ oracle_home_db }}"
# noqa unnamed-task
when: apply_patches_db

- include: transfer-files.yml
Expand All @@ -19,41 +21,42 @@

- name: db-opatch | Configure ocm.rsp (1)
template:
src=ocmrsp.expect.j2
dest={{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect
mode=0777
force=yes
src=ocmrsp.expect.j2
dest={{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect
mode=0777
force=yes
when: apply_patches_db and current_opatch_version.msg is version_compare('12.2.0.1.5', '<')
become: yes
become: true
become_user: "{{ oracle_user }}"
tags:
- ocmconfig

- name: db-opatch | Configure ocm.rsp (2)
shell: "{{ oracle_patch_stage }}/{{ db_version }}/ocmrsp.expect"
# noqa command-instead-of-shell
when: apply_patches_db and current_opatch_version.msg is version_compare('12.2.0.1.5', '<')
become: yes
become: true
become_user: "{{ oracle_user }}"
changed_when: False
changed_when: false
tags:
- ocmconfig

- name: db-opatch | Remove unwanted patches from DB
oracle_opatch:
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version}}/{{ item.path | default (item.patchid)}}/
patch_id={{item.patchid}}
patch_version={{ item.patchversion |default(omit)}}
exclude_upi={{ item.excludeUPI | default(omit)}}
opatchauto=False
conflict_check=True
stop_processes={{item.stop_processes |default(False)}}
ocm_response_file={{ ocm_response_file | default(omit)}}
output=verbose
state={{ item.state}}
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default (item.patchid) }}/
patch_id={{ item.patchid }}
patch_version={{ item.patchversion |default(omit) }}
exclude_upi={{ item.excludeUPI | default(omit) }}
opatchauto=False
conflict_check=True
stop_processes={{ item.stop_processes |default(False) }}
ocm_response_file={{ ocm_response_file | default(omit) }}
output=verbose
state={{ item.state }}
with_items:
- "{{db_homes_config[dbh.home]['opatch']}}"
become: yes
- "{{ db_homes_config[dbh.home]['opatch'] }}"
become: true
become_user: "{{ oracle_user }}"
tags:
- apply_patch_db
Expand All @@ -65,22 +68,22 @@

- name: db-opatch | Manage opatchauto patches for DB (non-gi)
oracle_opatch:
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version}}/{{ item.0.path | default (item.0.patchid)}}/{{ item.1}}
patch_id={{item.1}}
patch_version={{ item.1.patchversion |default(omit)}}
opatchauto=False
conflict_check=True
ocm_response_file={{ ocm_response_file | default(omit)}}
output=verbose
state={{ item.0.state }}
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version }}/{{ item.0.path | default (item.0.patchid) }}/{{ item.1 }}
patch_id={{ item.1 }}
patch_version={{ item.1.patchversion |default(omit) }}
opatchauto=False
conflict_check=True
ocm_response_file={{ ocm_response_file | default(omit) }}
output=verbose
state={{ item.0.state }}
with_subelements:
- "{{db_homes_config[dbh.home]['opatchauto']}}"
- subpatches
- flags:
skip_missing: True
#run_once: "{{ configure_cluster}}"
become: yes
- "{{ db_homes_config[dbh.home]['opatchauto'] }}"
- subpatches
- flags:
skip_missing: true
# run_once: "{{ configure_cluster}}"
become: true
become_user: "{{ oracle_user }}"
tags:
- apply_patch_db
Expand All @@ -89,52 +92,53 @@

- name: db-opatch | Manage opatchauto patches for DB (gi)
oracle_opatch:
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version}}/{{ item.path | default (item.patchid)}}/
patch_id={{item.patchid}}
patch_version={{ item.patchversion |default(omit)}}
opatchauto=True
conflict_check=True
ocm_response_file={{ ocm_response_file | default(omit)}}
output=verbose
state={{ item.state}}
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default (item.patchid) }}/
patch_id={{ item.patchid }}
patch_version={{ item.patchversion |default(omit) }}
opatchauto=True
conflict_check=True
ocm_response_file={{ ocm_response_file | default(omit) }}
output=verbose
state={{ item.state }}
with_items:
- "{{db_homes_config[dbh.home]['opatchauto']}}"
#run_once: "{{ configure_cluster}}"
become: yes
- "{{ db_homes_config[dbh.home]['opatchauto'] }}"
# run_once: "{{ configure_cluster}}"
become: true
tags:
- apply_patch_db
when: apply_patches_db and db_homes_config[dbh.home]['opatchauto'] is defined and olrloc.stat.exists
register: psuapplym

- name: db-opatch | Manage patches for DB
oracle_opatch:
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version}}/{{ item.path | default (item.patchid)}}/
patch_id={{item.patchid}}
patch_version={{ item.patchversion |default(omit)}}
exclude_upi={{ item.excludeUPI | default(omit)}}
opatchauto=False
conflict_check=True
stop_processes={{item.stop_processes |default(False)}}
ocm_response_file={{ ocm_response_file | default(omit)}}
output=verbose
state={{ item.state}}
oracle_home={{ oracle_home_db }}
patch_base={{ oracle_patch_install }}/{{ db_version }}/{{ item.path | default (item.patchid) }}/
patch_id={{ item.patchid }}
patch_version={{ item.patchversion |default(omit) }}
exclude_upi={{ item.excludeUPI | default(omit) }}
opatchauto=False
conflict_check=True
stop_processes={{ item.stop_processes |default(False) }}
ocm_response_file={{ ocm_response_file | default(omit) }}
output=verbose
state={{ item.state }}
with_items:
- "{{db_homes_config[dbh.home]['opatch']}}"
#run_once: "{{ configure_cluster}}"
become: yes
- "{{ db_homes_config[dbh.home]['opatch'] }}"
# run_once: "{{ configure_cluster }}"
become: true
become_user: "{{ oracle_user }}"
tags:
- apply_patch_db
when: apply_patches_db and db_homes_config[dbh.home]['opatch'] is defined
register: psuapplym

- name: db-opatch | Check patches
shell: "{{ oracle_home_db}}/OPatch/opatch lspatches -oh {{ oracle_home_db}}"
become: yes
shell: "{{ oracle_home_db }}/OPatch/opatch lspatches -oh {{ oracle_home_db }}"
# noqa command-instead-of-shell
become: true
become_user: "{{ oracle_user }}"
changed_when: False
changed_when: false
register: dbhome_patches

- name: db-opatch | Check patches
Expand Down
Loading

0 comments on commit 964ce99

Please sign in to comment.