Skip to content

Commit

Permalink
Merge pull request #574 from ministryofjustice/oracle-db-housekeeping…
Browse files Browse the repository at this point in the history
…-job

Created Oracle db housekeeping job and added role in ec2 db instance …
  • Loading branch information
Sandhya1874 authored Feb 27, 2024
2 parents 8ea13a8 + 6e03874 commit ac9d322
Show file tree
Hide file tree
Showing 26 changed files with 352 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ training_schema_refresh_cron:
dump_file: train_custom3_06042023.dmp
source_schema: train_custom3
target_schema: train_custom4

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,14 @@ db_configs:
asm_disk_groups: DATA,FLASH
service:
- { name: IWFM_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ db_configs:
asm_disk_groups: DATA,FLASH
service:
- { name: IWFM_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_hmpps_oem_preproduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ db_configs:
}
service:
- { name: EMREP_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_hmpps_oem_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ db_configs:
}
service:
- { name: EMREP_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_hmpps_oem_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ db_configs:
}
service:
- { name: EMREP_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ dns_search_domains:
osbws_additional_configs:
- name: osbws_prod
s3_bucket_name: ncr-db-backup-bucket20230823123102902900000001

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ dns_zone_internal: nomis-combined-reporting.hmpps-production.modernisation-platf
dns_search_domains:
- hmpps-oem.hmpps-production.modernisation-platform.internal
- azure.hmpp.root

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,14 @@ db_configs:

RCVCAT:
rcvcat_db_name: TRCVCAT

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_nomis_preproduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ rman_backup_cron:
minute: "30"
hour: "04"
# job: command generated in rman-backup-setup

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_nomis_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,14 @@ db_configs:
- { name: OLDNOMIS_TAF, role: PRIMARY }
- { name: NOMIS_APIRO_TAF, role: PHYSICAL_STANDBY }
- { name: OR_TAF, role: PHYSICAL_STANDBY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_nomis_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,14 @@ tns_entries:
host_list:
- test-oem-a.hmpps-oem.hmpps-test.modernisation-platform.internal
service_name: RCVCAT_TAF

# Oracle database housekeeping
audit_housekeeping_period: 30
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_oasys_preproduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,14 @@ db_configs:
}
service:
- { name: BIPINF_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_oasys_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ s3_bucket: prodpreprod-oasys-20230412084245180100000001

ords_trusted_origins:
production: "https://oasys.az.justice.gov.uk/eor,https://bridge-oasys.az.justice.gov.uk/eor,https://p-oasys.az.juistce.gov.uk/eor,https://www.oasys.service.justice.gov.uk/eor,https://int.oasys.service.justice.gov.uk/eor,http://localhost:8080/eor"

# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
11 changes: 11 additions & 0 deletions ansible/group_vars/environment_name_oasys_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,14 @@ db_configs:
}
service:
- { name: BIPINF_TAF, role: PRIMARY }

# Oracle database housekeeping
audit_housekeeping_period: 30
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
1 change: 1 addition & 0 deletions ansible/group_vars/server_type_csr_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ server_type_roles_list:
- tcp-keepalive
- oracle-19c
- oracle-db-backup
- oracle-db-housekeeping
- collectd
- amazon-cloudwatch-agent
- amazon-cloudwatch-agent-collectd
Expand Down
1 change: 1 addition & 0 deletions ansible/group_vars/server_type_hmpps_oem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ server_type_roles_list:
- oracle-secure-backup
- oracle-recovery-catalog
- oracle-db-backup
- oracle-db-housekeeping
- oracle-oms-setup
- collectd-service-metrics
- oracle-db-refresh
Expand Down
1 change: 1 addition & 0 deletions ansible/group_vars/server_type_ncr_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ roles_list:
- oracle-19c
- oracle-secure-backup
- oracle-db-backup
- oracle-db-housekeeping
- collectd
- amazon-cloudwatch-agent
- amazon-cloudwatch-agent-collectd
Expand Down
1 change: 1 addition & 0 deletions ansible/group_vars/server_type_nomis_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ server_type_roles_list:
- oracle-11g
- oracle-secure-backup
- oracle-db-backup
- oracle-db-housekeeping
- collectd
- amazon-cloudwatch-agent
- amazon-cloudwatch-agent-collectd
Expand Down
1 change: 1 addition & 0 deletions ansible/group_vars/server_type_oasys_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ roles_list:
# - oracle-db-standby-setup # manually run on a standby
- oracle-secure-backup
- oracle-db-backup
- oracle-db-housekeeping
- collectd
- amazon-cloudwatch-agent
- amazon-cloudwatch-agent-collectd
Expand Down
3 changes: 2 additions & 1 deletion ansible/group_vars/server_type_onr_db.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
ansible_python_interpreter: /usr/bin/python3.9
ansible_python_interpreter: /usr/bin/python3.6

users_and_groups_system:
- name: oracle
Expand Down Expand Up @@ -30,6 +30,7 @@ roles_list:
- oracle-11g
- oracle-secure-backup
- oracle-db-backup
- oracle-db-housekeeping
- collectd
- amazon-cloudwatch-agent
- amazon-cloudwatch-agent-collectd
Expand Down
20 changes: 20 additions & 0 deletions ansible/roles/oracle-db-housekeeping/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Overview

Role for configuring scheduled oracle Database server housekeeping.

# Pre-requisite for scheduled db server housekeeping

In group_vars add details for audit housekeeping
# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in

Example:
no_proxy="*" ansible-playbook site.yml --limit test-oem-a -e force_role=oracle-db-housekeeping
11 changes: 11 additions & 0 deletions ansible/roles/oracle-db-housekeeping/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Oracle database housekeeping
audit_housekeeping_period: 60
db_housekeeping_script: db_server_housekeeping.sh
housekeeping_cron:
db_server_housekeeping:
- name: database_server_housekeeping
weekday: "0"
minute: "30"
hour: "08"
# job: command generated in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Generate Housekeeping command parameters for scheduler
ansible.builtin.set_fact:
housekeeping_command: "/home/oracle/admin/scripts/{{ db_housekeeping_script }} -a {{ audit_housekeeping_period }}"

- name: create script directory
ansible.builtin.file:
path: "{{ item }}"
owner: oracle
group: oinstall
state: directory
recurse: yes
loop:
- /home/oracle/admin/scripts

- name: copy scripts
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/home/oracle/admin/scripts/{{ item }}"
owner: oracle
group: oinstall
mode: "0700"
loop:
- "{{ db_housekeeping_script }}"

- name: setup oracle housekeeping job
ansible.builtin.cron:
name: "{{ item.name }}"
weekday: "{{ item.weekday }}"
minute: "{{ item.minute }}"
hour: "{{ item.hour }}"
user: root
job: "su oracle -c '{{ housekeeping_command }}' 2>&1 | logger -p local3.info -t db_server_housekeeping"
loop: "{{ housekeeping_cron.db_server_housekeeping | list }}"
4 changes: 4 additions & 0 deletions ansible/roles/oracle-db-housekeeping/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- import_tasks: db-server-housekeeping.yml
tags:
- ec2provision
Loading

0 comments on commit ac9d322

Please sign in to comment.