Skip to content

Commit 5e09802

Browse files
Merge pull request #173 from ministryofjustice/DBA-562
Dba 562
2 parents 9a9da9d + 1ef3e7d commit 5e09802

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

.github/workflows/oracle-db-restore-points.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ jobs:
143143
playbooks/oracle_restore_points
144144
playbooks/block_sessions
145145
playbooks/oracle_password_rotation
146+
playbooks/oem_blackout
146147
playbooks/ansible.cfg
147148
path: operations
148149
ref: ${{ github.event.inputs.SourceCodeVersion }}
@@ -160,26 +161,30 @@ jobs:
160161
ref: ${{ github.event.inputs.SourceConfigVersion }}
161162
fetch-depth: 0
162163

163-
- name: Install yq
164-
uses: dcarbone/install-yq-action@v1.1.1
164+
- name: Checkout Ansible Required Roles From modernisation-platform-configuration-management
165+
uses: actions/checkout@v4
165166
with:
166-
download-compressed: true
167-
version: "v4.35.1"
168-
force: true
167+
repository: ministryofjustice/modernisation-platform-configuration-management
168+
sparse-checkout-cone-mode: false
169+
sparse-checkout: |
170+
ansible/roles/secretsmanager-passwords
171+
ansible/roles/get-modernisation-platform-facts
172+
path: roles
173+
ref: ${{ github.event.inputs.SourceConfigVersion }}
174+
fetch-depth: 0
169175

170176
- name: Define Targets
171177
id: definetargets
172178
working-directory: ${{ env.inventory }}
173179
run: |
174-
set -x
175180
targets=""
176181
prefix="environment_name_$(echo ${{ github.event.inputs.TargetEnvironment}} | sed 's/delius-core-dev/delius_core_development_dev/;s/delius-core-test/delius_core_test_test/;s/delius-core-training/delius_core_test_training/;s/delius-core-stage/delius_core_preproduction_stage/;s/delius-core-pre-prod/delius_core_preproduction_pre_prod/;s/delius-core-prod/delius_core_production_prod/')"
177182
build_targets() {
178183
databasetype=${1}
179-
high_availability_count=$(yq .high_availability_count.${databasetype} group_vars/${prefix}_all.yml)
180-
[ $high_availability_count -le 2 ] && targets="${targets}${prefix}_${databasetype}_primarydb,"
181-
[ $high_availability_count -eq 1 ] && targets="${targets}${prefix}_${databasetype}_standbydb1,"
182-
[ $high_availability_count -eq 2 ] && targets="${targets}${prefix}_${databasetype}_standbydb1,${prefix}_${databasetype}_standbydb2,"
184+
if [[ -e group_vars/${prefix}_${databasetype}_primarydb.yml ]]
185+
then
186+
targets="${targets}${prefix}_${databasetype}_dbs,"
187+
fi
183188
echo
184189
}
185190
[ "${{ github.event.inputs.IncludeDelius }}" == "yes" ] && build_targets delius
@@ -207,6 +212,7 @@ jobs:
207212
shell: bash
208213
run: |
209214
export ANSIBLE_CONFIG=$ansible_config
215+
ln -s $PWD/roles/ansible/roles $PWD/operations/playbooks/oracle_password_rotation/roles
210216
$command -i $inventory \
211217
-e target_dbs=${{ steps.definetargets.outputs.targets }} \
212218
-e "required_action='${{ github.event.inputs.RequiredAction }}'" \

playbooks/oracle_restore_points/playbook.yml

+21-26
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@
6868
- ( get_fast_start_failover.stdout | trim ) not in ['','Disabled']
6969

7070
# Allow OEM jobs to run during the flashback so we can pick up Audited Interaction Data for archival if required
71-
# - name: Start Blackout for Flashback
72-
# import_playbook: ../oem-blackout/playbook.yml
73-
# when: required_action == "Flashback to Restore Point"
74-
# vars:
75-
# target: "{{ target_dbs }}"
76-
# blackout: "Flashback_to_{{ restore_point_name }}"
77-
# object_type: all
78-
# action: start
79-
# allow_jobs: true
71+
- name: Start Blackout for Flashback
72+
import_playbook: ../oem_blackout/playbook.yml
73+
when: required_action == "Flashback to Restore Point"
74+
vars:
75+
target: "{{ target_dbs }}"
76+
blackout: "Flashback_to_{{ restore_point_name }}"
77+
object_type: all
78+
action: start
79+
allow_jobs: true
8080

8181
# Ensure all connections to Delius Primary are blocked and removed
8282
# prior to a Flashback
8383
- name: Block connections to Delius primary database
8484
import_playbook: ../block_sessions/playbook.yml
8585
vars:
86-
target_host: "{{ target_dbs.split(',') | select('search', '.*delius_primarydb') | first }}"
86+
target_host: "{{ target_dbs.split(',') | select('match','.*delius_dbs') | first | replace('dbs','primarydb') }}"
8787
database: { "delius": { "high_availability_count": 0 } }
8888
action: block
8989
when:
@@ -198,17 +198,12 @@
198198

199199
when: (restore_date_time | default() | length > 0) and database_primary_sid is defined
200200

201-
- name: Get environment name and application name
202-
set_fact:
203-
environment_name: "{{ hostvars[inventory_hostname].group_names[2] | replace(hostvars[inventory_hostname].group_names[2].split('_')[-1],'') }}"
204-
application_name: "{{ hostvars[inventory_hostname].group_names[3].split('_')[-2] }}"
205-
206201
- name: Create Oracle Standby Restore Points
207202
script: create_standby_restore_points.sh
208203
when: database_standby_sid is defined
209204
environment:
210205
RESTORE_POINT_NAME: "{{ uplift_restore_point_name | default(restore_point_name) | upper }}"
211-
SCN: "{{ hostvars[groups[environment_name + application_name + '_primarydb'][0]]['scn'] | default('0') }}"
206+
SCN: "{{ hostvars[groups[hostvars[inventory_hostname].group_names | select('match','.*_dbs') | first | replace('dbs','primarydb')][0]]['scn'] | default('0') }}"
212207

213208
- name: Create Oracle Primary Restore Points
214209
script: create_primary_restore_points.sh
@@ -306,7 +301,7 @@
306301
- name: Unblock connections to Delius primary database
307302
import_playbook: ../block_sessions/playbook.yml
308303
vars:
309-
target_host: "{{ target_dbs.split(',') | select('search', '.*delius_primarydb') | first }}"
304+
target_host: "{{ target_dbs.split(',') | select('match','.*delius_dbs') | first | replace('dbs','primarydb') }}"
310305
database: { "delius": { "high_availability_count": 0 } }
311306
action: unblock
312307
ignore_flashback: true
@@ -389,7 +384,7 @@
389384
# out of Sync with those in SSM Parameter store and OEM. Rotate the passwords again to sync everything up.
390385
# (This step is skipped if not in AWS since there will be no password store)
391386
- name: Rotate Database Passwords
392-
import_playbook: ../oracle_password_rotation/password_rotation.yml
387+
import_playbook: ../oracle_password_rotation/database_password_rotation.yml
393388
vars:
394389
rotate_database_passwords: true
395390
rotate_groups: "{{ target_dbs }}"
@@ -445,14 +440,14 @@
445440
- database_primary_sid is defined
446441
- database_primary_sid | regex_search('STGMIS')
447442

448-
# - name: Stop Blackout for Flashback
449-
# import_playbook: ../oem-blackout/playbook.yml
450-
# when: required_action == "Flashback to Restore Point"
451-
# vars:
452-
# target: "{{ target_dbs }}"
453-
# blackout: "Flashback_to_{{ restore_point_name }}"
454-
# object_type: all
455-
# action: stop
443+
- name: Stop Blackout for Flashback
444+
import_playbook: ../oem_blackout/playbook.yml
445+
when: required_action == "Flashback to Restore Point"
446+
vars:
447+
target: "{{ target_dbs }}"
448+
blackout: "Flashback_to_{{ restore_point_name }}"
449+
object_type: all
450+
action: stop
456451

457452
# Always Run the Restore Point Report at the End
458453
- name: Report restore points

0 commit comments

Comments
 (0)