Skip to content

Commit 1653415

Browse files
committed
Merge branch 'DBA-828-Replace-Oracle-Internal-Audit-with-Unified-Audit-Trail' of https://github.com/ministryofjustice/hmpps-delius-operational-automation into DBA-828-Replace-Oracle-Internal-Audit-with-Unified-Audit-Trail
2 parents fd88a74 + 0ff66e4 commit 1653415

File tree

4 files changed

+79
-84
lines changed

4 files changed

+79
-84
lines changed

playbooks/audit_management/enable_unified_audit.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
changed_when: false
88

99
- name: Run Audit Management on Primary Databases
10-
when:
10+
when:
1111
- unified_audit_option is defined
1212
- unified_audit_option.stdout | trim == '0'
1313
block:
@@ -28,7 +28,7 @@
2828
- name: Stop Database
2929
shell: |
3030
. ~/.bash_profile
31-
srvctl stop database -d $ORACLE_SID -stopoption immediate
31+
srvctl stop database -d $ORACLE_SID -stopoption immediate
3232
changed_when: false
3333

3434
- name: Link Oracle binary with uniaud_on to Enable Unified Auditing
@@ -42,4 +42,3 @@
4242
. ~/.bash_profile
4343
srvctl start database -d $ORACLE_SID
4444
changed_when: false
45-

playbooks/audit_management/playbook.yml

+71-74
Original file line numberDiff line numberDiff line change
@@ -8,86 +8,83 @@
88
any_errors_fatal: true
99

1010
tasks:
11-
- name: Get Database Role
12-
script: ../../common/files/get_database_role.sh
13-
register: getdatabaserole
14-
changed_when: false
11+
- name: Get Database Role
12+
script: ../../common/files/get_database_role.sh
13+
register: getdatabaserole
14+
changed_when: false
1515

16-
- name: Set Database Role
17-
set_fact:
18-
database_role: "{{ getdatabaserole.stdout_lines[-1] }}"
19-
20-
- name: Check Unified Audit Management is enabled
21-
script: get_unified_auditing.sh
22-
register: unified_audit_enabled
23-
changed_when: false
16+
- name: Set Database Role
17+
set_fact:
18+
database_role: "{{ getdatabaserole.stdout_lines[-1] }}"
2419

25-
- name: Run Audit Management on Primary Databases
26-
when:
27-
- database_role == 'PRIMARY'
28-
block:
29-
- name: Copy SQL files
30-
copy:
31-
src: "{{ item }}"
32-
dest: "/tmp"
33-
owner: oracle
34-
group: oinstall
35-
with_items:
36-
- delius_audit_management.sql
37-
- delius_audit_unified_setup.sql
38-
- delius_audit_archive_job.sql
39-
- delius_audit_timestamp_job.sql
40-
- gen_uniaud_policies.sql
41-
changed_when: false
20+
- name: Check Unified Audit Management is enabled
21+
script: get_unified_auditing.sh
22+
register: unified_audit_enabled
23+
changed_when: false
4224

43-
- name: Compile Audit Package
44-
shell: |
45-
. ~/.bash_profile
46-
sqlplus -s / as sysdba <<EOF
47-
@/tmp/delius_audit_management.sql
48-
EOF
49-
register: sql_result
50-
changed_when: false
51-
failed_when: "'Package body created.' not in sql_result.stdout"
25+
- name: Run Audit Management on Primary Databases
26+
when:
27+
- database_role == 'PRIMARY'
28+
block:
29+
- name: Copy SQL files
30+
copy:
31+
src: "{{ item }}"
32+
dest: "/tmp"
33+
owner: oracle
34+
group: oinstall
35+
with_items:
36+
- delius_audit_management.sql
37+
- delius_audit_unified_setup.sql
38+
- delius_audit_archive_job.sql
39+
- delius_audit_timestamp_job.sql
40+
- gen_uniaud_policies.sql
41+
changed_when: false
5242

53-
- name: Configure Audit in Database
54-
shell: |
55-
. ~/.bash_profile
56-
sqlplus -s / as sysdba <<EOF
57-
@/tmp/delius_audit_unified_setup.sql
58-
EOF
59-
register: sql_result
60-
changed_when: false
61-
failed_when: "'Audit Management' not in sql_result.stdout"
43+
- name: Compile Audit Package
44+
shell: |
45+
. ~/.bash_profile
46+
sqlplus -s / as sysdba <<EOF
47+
@/tmp/delius_audit_management.sql
48+
EOF
49+
register: sql_result
50+
changed_when: false
51+
failed_when: "'Package body created.' not in sql_result.stdout"
6252

63-
- name: Schedule Audit Cleanup Job
64-
shell: |
65-
. ~/.bash_profile
66-
sqlplus -s / as sysdba <<EOF
67-
@/tmp/delius_audit_archive_job.sql
68-
EOF
69-
register: sql_result
70-
changed_when: false
71-
failed_when: "'Audit Management' not in sql_result.stdout"
53+
- name: Configure Audit in Database
54+
shell: |
55+
. ~/.bash_profile
56+
sqlplus -s / as sysdba <<EOF
57+
@/tmp/delius_audit_unified_setup.sql
58+
EOF
59+
register: sql_result
60+
changed_when: false
61+
failed_when: "'Audit Management' not in sql_result.stdout"
7262

73-
- name: Schedule Archiving Timestamp Job
74-
shell: |
75-
. ~/.bash_profile
76-
sqlplus -s / as sysdba <<EOF
77-
@/tmp/delius_audit_timestamp_job.sql
78-
EOF
79-
register: sql_result
80-
changed_when: false
81-
failed_when: "'Audit Management' not in sql_result.stdout"
82-
83-
- name: Configure Audit Policies
84-
import_tasks: recreate_uniaud_policies.yml
85-
86-
# server side tasks that need to be run on all hosts
87-
- name: Enable Unified Audit on Host
88-
when:
89-
- "'FALSE' in unified_audit_enabled.stdout"
90-
import_tasks: enable_unified_audit.yml
63+
- name: Schedule Audit Cleanup Job
64+
shell: |
65+
. ~/.bash_profile
66+
sqlplus -s / as sysdba <<EOF
67+
@/tmp/delius_audit_archive_job.sql
68+
EOF
69+
register: sql_result
70+
changed_when: false
71+
failed_when: "'Audit Management' not in sql_result.stdout"
9172

73+
- name: Schedule Archiving Timestamp Job
74+
shell: |
75+
. ~/.bash_profile
76+
sqlplus -s / as sysdba <<EOF
77+
@/tmp/delius_audit_timestamp_job.sql
78+
EOF
79+
register: sql_result
80+
changed_when: false
81+
failed_when: "'Audit Management' not in sql_result.stdout"
9282

83+
- name: Configure Audit Policies
84+
import_tasks: recreate_uniaud_policies.yml
9385

86+
# server side tasks that need to be run on all hosts
87+
- name: Enable Unified Audit on Host
88+
when:
89+
- "'FALSE' in unified_audit_enabled.stdout"
90+
import_tasks: enable_unified_audit.yml

playbooks/audit_management/recreate_uniaud_policies.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
EOF
3535
register: sql_result
3636
changed_when: false
37-
failed_when:
38-
- "'ORA-' in sql_result.stdout"
37+
failed_when:
38+
- "'ORA-' in sql_result.stdout"
3939

4040
- name: Remove Existing Policies
4141
shell: |
@@ -47,8 +47,8 @@
4747
EOF
4848
register: sql_result
4949
changed_when: false
50-
failed_when:
51-
- "'ORA-' in sql_result.stdout"
50+
failed_when:
51+
- "'ORA-' in sql_result.stdout"
5252

5353
- name: Create Auditing Policies
5454
shell: |
@@ -58,5 +58,5 @@
5858
EOF
5959
register: sql_result
6060
changed_when: false
61-
failed_when:
62-
- "'ORA-' in sql_result.stdout"
61+
failed_when:
62+
- "'ORA-' in sql_result.stdout"

playbooks/delius-artefacts-playbook.yml

-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,3 @@
9494
- name: Deploy Audit Management
9595
include_tasks: audit_management/playbook.yml
9696
when: deploy_audit | default('no') == "yes"
97-

0 commit comments

Comments
 (0)