From 2b6915967f7ac174cf96115d254b93e93c06ffe0 Mon Sep 17 00:00:00 2001 From: sandhya1874 Date: Fri, 5 Apr 2024 09:03:13 +0100 Subject: [PATCH 1/5] . --- .../tasks/get_latest_backup_control_file.yml | 8 ++++---- .../templates/get_latest_backup_control_file.sql.j2 | 2 +- ansible/roles/oracle-db-refresh/vars/main.yml | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml b/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml index fbccb2e28..717930d71 100644 --- a/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml +++ b/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml @@ -24,8 +24,8 @@ - name: Copy the latest backup control file handle details to the runner fetch: - src: /tmp/{{ ORACLE_DB_REFRESH_FILE }} - dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ ORACLE_DB_REFRESH_FILE }}" + src: "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" + dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" flat: yes fail_on_missing: yes @@ -34,5 +34,5 @@ path: "{{ item }}" state: absent loop: - - "/tmp/get_latest_backup_control_file.sql" - - "/tmp/{{ ORACLE_DB_REFRESH_FILE }}" + - "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" + - "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}" diff --git a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 index 241585547..743bef99f 100644 --- a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 +++ b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 @@ -1,5 +1,5 @@ set head off echo off feedback off -spool /tmp/{{ ORACLE_DB_REFRESH_FILE }} +spool /tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt with controlfile_details as ( select db_key, max(stamp) stamp from rcvcatowner.rc_backup_controlfile diff --git a/ansible/roles/oracle-db-refresh/vars/main.yml b/ansible/roles/oracle-db-refresh/vars/main.yml index cb007edf2..225af7453 100644 --- a/ansible/roles/oracle-db-refresh/vars/main.yml +++ b/ansible/roles/oracle-db-refresh/vars/main.yml @@ -1,3 +1,2 @@ --- ORACLE_DB_REFRESH_DB_NAME: "" -ORACLE_DB_REFRESH_FILE: "latest_backup_control_file.txt" From c6f1cdfb838823c93d4f5abcaf05e1609cbcb1da Mon Sep 17 00:00:00 2001 From: sandhya1874 Date: Fri, 5 Apr 2024 09:32:28 +0100 Subject: [PATCH 2/5] . --- .../tasks/get_latest_backup_control_file.yml | 14 +++++++------- ansible/roles/oracle-db-refresh/tasks/main.yml | 7 ++++++- .../tasks/oracle_db_restore.yml | 18 ++++++++++++++++++ .../get_latest_backup_control_file.sql.j2 | 4 ++-- ansible/roles/oracle-db-refresh/vars/main.yml | 2 -- 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml delete mode 100644 ansible/roles/oracle-db-refresh/vars/main.yml diff --git a/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml b/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml index 717930d71..0746886c1 100644 --- a/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml +++ b/ansible/roles/oracle-db-refresh/tasks/get_latest_backup_control_file.yml @@ -1,8 +1,8 @@ --- -- name: Check if ORACLE_DB_REFRESH_DB_NAME is defined +- name: Check if SOURCE_DB is defined fail: - msg: "ORACLE_DB_REFRESH_DB_NAME is not defined" - when: ORACLE_DB_REFRESH_DB_NAME == "" + msg: "SOURCE_DB is not defined" + when: SOURCE_DB == "" - name: Install SQL Script template: @@ -24,8 +24,8 @@ - name: Copy the latest backup control file handle details to the runner fetch: - src: "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" - dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" + src: "/tmp/{{ SOURCE_DB }}_control.txt" + dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ SOURCE_DB }}_control.txt" flat: yes fail_on_missing: yes @@ -34,5 +34,5 @@ path: "{{ item }}" state: absent loop: - - "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt" - - "/tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}" + - "/tmp/{{ SOURCE_DB }}_control.txt" + - "/tmp/get_latest_backup_control_file.sql" diff --git a/ansible/roles/oracle-db-refresh/tasks/main.yml b/ansible/roles/oracle-db-refresh/tasks/main.yml index cdbab5273..d3fafc489 100644 --- a/ansible/roles/oracle-db-refresh/tasks/main.yml +++ b/ansible/roles/oracle-db-refresh/tasks/main.yml @@ -2,4 +2,9 @@ - import_tasks: get_latest_backup_control_file.yml tags: - oracle_db_refresh - - oracle_db_refresh_get_latest_backup_control_file + - get_latest_backup_control_file + +- import_tasks: oracle_db_restore.yml + tags: + - oracle_db_refresh + - refresh_db \ No newline at end of file diff --git a/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml b/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml new file mode 100644 index 000000000..ae848480a --- /dev/null +++ b/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml @@ -0,0 +1,18 @@ +--- +- name: Check if TARGET_DB is defined + fail: + msg: "TARGET_DB is not defined" + when: TARGET_DB == "" + +- name: Check if SOURCE_DB is defined + fail: + msg: "SOURCE_DB is not defined" + when: SOURCE_DB == "" + +- name: Copy the latest backup control file handle details to the runner + fetch: + src: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ SOURCE_DB }}_control.txt" + dest: "/tmp/{{ TARGET_DB }}_control.txt" + flat: yes + fail_on_missing: yes + diff --git a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 index 743bef99f..72cd10ea7 100644 --- a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 +++ b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 @@ -1,9 +1,9 @@ set head off echo off feedback off -spool /tmp/{{ ORACLE_DB_REFRESH_DB_NAME }}_control.txt +spool /tmp/{{ SOURCE_DB }}_control.txt with controlfile_details as ( select db_key, max(stamp) stamp from rcvcatowner.rc_backup_controlfile - where autobackup_date is NULL and db_name = '{{ ORACLE_DB_REFRESH_DB_NAME }}' + where autobackup_date is NULL and db_name = '{{ SOURCE_DB }}' group by db_key ) select a.HANDLE from rcvcatowner.rc_backup_piece a, controlfile_details b, rcvcatowner.rc_backup_controlfile c diff --git a/ansible/roles/oracle-db-refresh/vars/main.yml b/ansible/roles/oracle-db-refresh/vars/main.yml deleted file mode 100644 index 225af7453..000000000 --- a/ansible/roles/oracle-db-refresh/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -ORACLE_DB_REFRESH_DB_NAME: "" From 18658f108b6344826e292dfe0bff5a20a5032c56 Mon Sep 17 00:00:00 2001 From: sandhya1874 Date: Fri, 5 Apr 2024 09:33:46 +0100 Subject: [PATCH 3/5] . --- ansible/roles/oracle-db-refresh/tasks/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible/roles/oracle-db-refresh/tasks/main.yml b/ansible/roles/oracle-db-refresh/tasks/main.yml index d3fafc489..43360fda4 100644 --- a/ansible/roles/oracle-db-refresh/tasks/main.yml +++ b/ansible/roles/oracle-db-refresh/tasks/main.yml @@ -3,8 +3,10 @@ tags: - oracle_db_refresh - get_latest_backup_control_file + - never - import_tasks: oracle_db_restore.yml tags: - oracle_db_refresh - - refresh_db \ No newline at end of file + - refresh_db + - never \ No newline at end of file From f84ea87e7961d8fff80981de57fb3cf3887c8455 Mon Sep 17 00:00:00 2001 From: sandhya1874 Date: Fri, 5 Apr 2024 09:35:56 +0100 Subject: [PATCH 4/5] . --- ansible/roles/oracle-db-refresh/tasks/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/ansible/roles/oracle-db-refresh/tasks/main.yml b/ansible/roles/oracle-db-refresh/tasks/main.yml index 43360fda4..25eff1731 100644 --- a/ansible/roles/oracle-db-refresh/tasks/main.yml +++ b/ansible/roles/oracle-db-refresh/tasks/main.yml @@ -3,10 +3,8 @@ tags: - oracle_db_refresh - get_latest_backup_control_file - - never - import_tasks: oracle_db_restore.yml tags: - oracle_db_refresh - refresh_db - - never \ No newline at end of file From 12c4c1a1e58f535e3ea3e9dc8d1aadb5802fe05c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 5 Apr 2024 08:38:59 +0000 Subject: [PATCH 5/5] Commit changes made by code formatters --- ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml b/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml index ae848480a..da2160452 100644 --- a/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml +++ b/ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml @@ -15,4 +15,3 @@ dest: "/tmp/{{ TARGET_DB }}_control.txt" flat: yes fail_on_missing: yes -