-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from ministryofjustice/oracle_psu_patching
Oracle 19c psu patching
- Loading branch information
Showing
18 changed files
with
260 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Download Oracle 19c patches from S3 bucket | ||
amazon.aws.aws_s3: | ||
bucket: "{{ artefacts_s3_bucket_name }}" | ||
object: "{{ artefacts_s3_bucket_path }}/{{ item }}" | ||
dest: "{{ stage }}/{{ item }}" | ||
mode: get | ||
overwrite: latest | ||
loop: | ||
- "{{ oracle_patch.psu_patch }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,4 @@ | |
loop: | ||
- "{{ db_software }}" | ||
- "{{ grid_software }}" | ||
- "{{ psu_patch }}" | ||
- "{{ opatch }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- name: Get OPatch Version | ||
ansible.builtin.shell: | | ||
export ORACLE_HOME={{ grid_home }} | ||
{{ grid_home }}/OPatch/opatch version | head -1 | cut -d' ' -f3 | grep {{ oracle_patch.opatch_version }} | wc -l | ||
register: grid_required_version_check | ||
|
||
- name: Upgrade OPatch | ||
block: | ||
- name: Backup previous OPatch folder | ||
ansible.builtin.archive: | ||
path: "{{ item }}/OPatch" | ||
dest: "{{ item }}/OPatch_{{ bkpdate }}.zip" | ||
format: zip | ||
remove: yes | ||
owner: oracle | ||
group: oinstall | ||
loop: | ||
- "{{ database_home }}" | ||
- "{{ grid_home }}" | ||
|
||
- name: Download Oracle 19c PSU patch and OPatch files from S3 bucket | ||
amazon.aws.aws_s3: | ||
bucket: "{{ artefacts_s3_bucket_name }}" | ||
object: "{{ artefacts_s3_bucket_path }}/{{ item }}" | ||
dest: "{{ stage }}/{{ item }}" | ||
mode: get | ||
overwrite: latest | ||
loop: | ||
- "{{ psu_patch }}" | ||
- "{{ opatch }}" | ||
|
||
- name: Unarchive Opatch | ||
ansible.builtin.unarchive: | ||
src: "{{ stage }}/{{ opatch_zip }}" | ||
dest: "{{ item }}" | ||
owner: oracle | ||
group: oinstall | ||
mode: u=rwx,g=rx,o=rx | ||
remote_src: yes | ||
loop: | ||
- "{{ database_home }}" | ||
- "{{ grid_home }}" | ||
|
||
#block | ||
when: grid_required_version_check == "0" | ||
become: true | ||
become_user: "{{ oracle_install_user }}" | ||
environment: | ||
ORACLE_HOME: "{{ grid_home }}" | ||
PATH: "{{ grid_home }}/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin" |
72 changes: 72 additions & 0 deletions
72
ansible/roles/oracle-19c/tasks/oracle_ojvm_patch_upgrade.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
- name: Get OJVM patch details | ||
ansible.builtin.shell: | | ||
export ORACLE_HOME={{ database_home }} | ||
{{ database_home }}/OPatch/opatch lspatches | grep {{ oracle_patch.ojvm_patch_string }} | wc -l | ||
register: ojvm_patch_version_check | ||
|
||
- name: OJVM patch upgrade | ||
block: | ||
- name: Shutdown databases before applying OJVM patch | ||
ansible.builtin.shell: | | ||
export ORACLE_SID=+ASM | ||
export ORAENV_ASK=NO | ||
. oraenv | ||
srvctl stop home -oraclehome {{ database_home }} -statefile /tmp/instances.txt | ||
- name: Deploy OJVM Patch | ||
ansible.builtin.shell: | | ||
cd "{{ stage }}/{{ oracle_patch.oracle_combo_patch }}/{{ oracle_patch.oracle_ojvm_patch }}" | ||
export ORACLE_SID=`grep {{ database_home }} /etc/oratab | grep "^[^#;]" | awk -F: '{ print $1 }' | head -1` | ||
. oraenv | ||
$ORACLE_HOME/OPatch/opatch apply -silent | ||
register: ojvm_patch_upgrade | ||
async: 1800 | ||
poll: 60 | ||
|
||
- name: Start databases before applying OJVM patch | ||
ansible.builtin.shell: | | ||
export ORACLE_SID=+ASM | ||
export ORAENV_ASK=NO | ||
. oraenv | ||
srvctl start home -oraclehome {{ database_home }} -statefile /tmp/instances.txt | ||
- name: Copy datapatch upgrade script | ||
template: | ||
src: "{{ item }}.j2" | ||
dest: "{{ stage }}/{{ item }}" | ||
owner: "{{ oracle_install_user }}" | ||
group: "{{ oracle_install_group }}" | ||
mode: "0700" | ||
loop: | ||
- "run_datapatch.sh" | ||
|
||
- name: Run datapatch | ||
ansible.builtin.shell: "{{ stage }}/run_datapatch.sh" | ||
register: datapatch_upgrade | ||
async: 9600 | ||
poll: 0 | ||
|
||
- name: Wait for datapatch upgrade to complete | ||
ansible.builtin.async_status: | ||
jid: "{{ datapatch_upgrade.ansible_job_id }}" | ||
register: datapatch_upgrade | ||
until: datapatch_upgrade.finished | ||
delay: 60 | ||
retries: 180 | ||
|
||
- name: Restart databases | ||
ansible.builtin.shell: | | ||
export ORACLE_SID=+ASM | ||
export ORAENV_ASK=NO | ||
. oraenv | ||
srvctl stop home -oraclehome {{ database_home }} -statefile /tmp/instances2.txt | ||
srvctl start home -oraclehome {{ database_home }} -statefile /tmp/instances2.txt | ||
#block | ||
when: ojvm_patch_version_check.stdout == "0" | ||
become: yes | ||
become_user: "{{ oracle_install_user }}" | ||
environment: | ||
ORACLE_HOME: "{{ database_home }}" | ||
PATH: "{{ database_home }}/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: Get RU patch details | ||
ansible.builtin.shell: | | ||
export ORACLE_HOME={{ grid_home }} | ||
{{ grid_home }}/OPatch/opatch lspatches | grep {{ oracle_patch.patch_string }} | wc -l | ||
register: grid_patch_version_check | ||
|
||
- name: RU patch upgrade | ||
block: | ||
- name: Kill sqlplus sessions if there are any | ||
ansible.builtin.shell: | | ||
if [ `ps -fu oracle | grep sqlplus | grep -v grep | wc -l` -gt 0 ] | ||
then | ||
ps -fu oracle | grep sqlplus | grep -v grep | gawk '{print $2}' | xargs kill -9 | ||
fi | ||
- name: Download Oracle 19c PSU patch from S3 bucket | ||
amazon.aws.aws_s3: | ||
bucket: "{{ artefacts_s3_bucket_name }}" | ||
object: "{{ artefacts_s3_bucket_path }}/{{ item }}" | ||
dest: "{{ stage }}/{{ item }}" | ||
mode: get | ||
overwrite: latest | ||
loop: | ||
- "{{ oracle_patch.psu_patch }}" | ||
|
||
- name: Unarchive RU patch | ||
ansible.builtin.unarchive: | ||
src: "{{ stage }}/{{ oracle_patch.psu_patch }}" | ||
dest: "{{ stage }}" | ||
owner: oracle | ||
group: oinstall | ||
mode: u=rwx,g=rx,o=rx | ||
remote_src: yes | ||
|
||
- name: Deploy OPatch | ||
ansible.builtin.shell: | | ||
$ORACLE_HOME/OPatch/opatchauto apply "{{ stage }}/{{ oracle_patch.oracle_combo_patch }}/{{ oracle_patch.oracle_release_update }}" | ||
register: ru_patch_upgrade | ||
async: 9600 | ||
poll: 0 | ||
|
||
- name: Wait for RU patch upgrade to complete | ||
ansible.builtin.async_status: | ||
jid: "{{ ru_patch_upgrade.ansible_job_id }}" | ||
register: ru_patch_upgrade | ||
until: ru_patch_upgrade.finished | ||
delay: 60 | ||
retries: 180 | ||
|
||
#block | ||
when: grid_patch_version_check.stdout == "0" | ||
environment: | ||
ORACLE_HOME: "{{ grid_home }}" | ||
PATH: "{{ grid_home }}/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- import_tasks: opatch_upgrade.yml | ||
|
||
- import_tasks: oracle_patch_upgrade.yml | ||
|
||
- import_tasks: oracle_ojvm_patch_upgrade.yml | ||
# - import_tasks: oracle_bug_fixes.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
export ORAENV_ASK=NO | ||
echo -e "set head off \n select 'OPEN_MODE='||decode (open_mode,'READ WRITE',0,-1) from v\$database; \n select '=VERSION='|| version from v\$instance; \n exit" > {{ stage }}/db_check.sql | ||
for i in `ps -fe| grep pmon| grep -v "+ASM"| grep -v grep | awk -F_ '{ print $3 }'` | ||
do | ||
export ORACLE_SID=$i | ||
. oraenv >/dev/null | ||
DB_STATUS=`sqlplus -s "/ as sysdba" @{{ stage }}/db_check.sql` | ||
DB_OPEN=`echo $DB_STATUS| awk -F= '{ print $2 }'` | ||
DB_VERSION=`echo $DB_STATUS| awk -F= '{ print $4 }'` | ||
if [ ${DB_OPEN} == 0 ] | ||
then | ||
if [ ${DB_VERSION} == "19.0.0.0.0" ] | ||
then | ||
echo "Running datapatch for " $i | ||
$ORACLE_HOME/OPatch/datapatch -verbose & | ||
fi | ||
fi | ||
done | ||
wait | ||
echo "All databases successfully upgraded with latest patch" |