Skip to content

Commit 4dae3be

Browse files
authored
Merge pull request #273 from Rendanic/prrooh
Support for read-only ORACLE_HOMEs
2 parents 6a3ae5e + d6d3165 commit 4dae3be

File tree

9 files changed

+63
-45
lines changed

9 files changed

+63
-45
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "Support of Read-Only ORACLE_HOMEs (#273)"

roles/oradb_manage_db/defaults/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ listener_home: "{%- if lsnrinst is defined -%}\
6666
{%- endif -%}\
6767
{%- endif -%}"
6868

69+
listener_home_config: "{%- if lsnrinst is defined -%}\
70+
{%- if db_homes_config[lsnrinst.home]['readonly_home'] | default(false) -%}{{ oracle_base }}/homes/{{ db_homes_config[lsnrinst.home]['oracle_home_name'] }}\
71+
{%- else -%}{{ listener_home }}\
72+
{%- endif -%}\
73+
{%- elif tnsinst is defined -%}\
74+
{%- if db_homes_config[tnsinst.home]['readonly_home'] | default(false) -%}{{ oracle_base }}/homes/{{ db_homes_config[tnsinst.home]['oracle_home_name'] }}\
75+
{%- else -%}{{ listener_home }}\
76+
{%- endif -%}\
77+
{%- elif sqlnetinst is defined -%}\
78+
{%- if db_homes_config[sqlnetinst.home]['readonly_home'] | default(false) -%}{{ oracle_base }}/homes/{{ db_homes_config[sqlnetinst.home]['oracle_home_name'] }}\
79+
{%- else -%}{{ listener_home }}\
80+
{%- endif -%}\
81+
{%- endif -%}"
82+
6983
oracle_env_lsnrctl:
7084
ORACLE_BASE: "{{ oracle_base }}"
7185
ORACLE_HOME: "{{ listener_home }}"

roles/oradb_manage_db/tasks/listener_details.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
- ansible.builtin.debug: msg="ORACLE_HOME {{ listener_home }}" # noqa unnamed-task
2+
- ansible.builtin.debug: msg="ORACLE_BASE_HOME {{ listener_home_config }}" # noqa unnamed-task
33
tags: listener2
44

55
- name: listener | create custom configuration in listener.ora
66
ansible.builtin.blockinfile:
7-
path: "{{ listener_home }}/network/admin/listener.ora"
7+
path: "{{ listener_home_config }}/network/admin/listener.ora"
88
backup: true
99
create: true
1010
mode: 0644

roles/oradb_manage_db/tasks/sqlnet.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
- ansible.builtin.debug: msg="sqlnet in ORACLE_HOME {{ listener_home }}" # noqa unnamed-task
2+
- ansible.builtin.debug: msg="ORACLE_BASE_HOME {{ listener_home_config }}" # noqa unnamed-task
33
tags: sqlnet2
44

55
- name: sqlnet.ora | create IFILE entry in sqlnet.ora
66
ansible.builtin.lineinfile:
7-
line: "IFILE={{ listener_home }}/network/admin/sqlnet_ansible.ora"
7+
line: "IFILE={{ listener_home_config }}/network/admin/sqlnet_ansible.ora"
88
regexp: "^IFILE=/"
99
insertbefore: BOF
10-
path: "{{ listener_home }}/network/admin/sqlnet.ora"
10+
path: "{{ listener_home_config }}/network/admin/sqlnet.ora"
1111
backup: true
1212
create: true
1313
group: "{{ oracle_group }}"
@@ -18,7 +18,7 @@
1818

1919
- name: sqlnet.ora | create custom configuration in sqlnet_ansible.ora
2020
ansible.builtin.lineinfile:
21-
path: "{{ listener_home }}/network/admin/sqlnet_ansible.ora"
21+
path: "{{ listener_home_config }}/network/admin/sqlnet_ansible.ora"
2222
line: "{{ item.name }}={{ item.value }}"
2323
regexp: "^{{ item.name }}="
2424
backup: true

roles/oradb_manage_db/tasks/tnsnames.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
- ansible.builtin.debug: msg="ORACLE_HOME {{ listener_home }}" # noqa unnamed-task
2+
- ansible.builtin.debug: msg="ORACLE_BASE_HOME {{ listener_home_config }}" # noqa unnamed-task
33
tags: tnsnames
44

55
- name: tnsnames.ora | create IFILE entry in tnsnames.ora
66
ansible.builtin.lineinfile:
77
line: "IFILE={{ listener_home }}/network/admin/tnsnames_ansible.ora"
88
regexp: "^IFILE=/"
99
insertbefore: BOF
10-
path: "{{ listener_home }}/network/admin/tnsnames.ora"
10+
path: "{{ listener_home_config }}/network/admin/tnsnames.ora"
1111
backup: true
1212
create: true
1313
group: "{{ oracle_group }}"
@@ -18,7 +18,7 @@
1818

1919
- name: tnsnames.ora | create custom configuration in tnsnames_ansible.ora
2020
ansible.builtin.blockinfile:
21-
path: "{{ listener_home }}/network/admin/tnsnames_ansible.ora"
21+
path: "{{ listener_home_config }}/network/admin/tnsnames_ansible.ora"
2222
backup: true
2323
create: true
2424
group: "{{ oracle_group }}"

roles/oraswdb_install/defaults/main.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,8 @@ oracle_sw_extract_path: "{%- if '18' in db_version -%}\
2222
{{ oracle_stage }}/{{ item[0].version }}\
2323
{%- endif -%}"
2424

25-
# oracle_home_db: "{% if dbh is defined %}
26-
# {%- if dbh.oracle_home is defined %}{{ dbh.oracle_home }}
27-
# {%- else %}{{ oracle_base}}/{{ dbh.oracle_version_db }}/{{ dbh.home }}
28-
# {%- endif %}
29-
# {%- elif item.0 is defined %}
30-
# {%- if item.0.oracle_home is defined %}{{ item.0.oracle_home}}
31-
# {%- else %}{{ oracle_base }}/{{ item.0.oracle_version_db }}/{{ item.0.home }}
32-
# {%- endif %}
33-
# {%- elif item is defined %}
34-
# {%- if item.oracle_home is defined %}{{ item.oracle_home}}
35-
# {%- else %}{{ oracle_base }}/{{ item.oracle_version_db }}/{{ item.home }}
36-
# {%- endif %}
37-
# {%- endif %}"
38-
39-
4025
oracle_profile_name: ".profile_{{ dbh.home }}"
4126

42-
# "{%- if item is defined -%}
43-
# {%- if item.oracle_home is defined -%}
44-
# .profile_{{ item.oracle_home |basename}}_{{ item.oracle_version_db}}
45-
# {%- elif item.home is defined -%}
46-
# .profile_{{ item.home }}_{{item.oracle_version_db}}
47-
# {%- elif item.oracle_home is defined -%}
48-
# .profile_{{item.oracle_home |basename}}_{{item.oracle_version_db}}
49-
# {%- endif- %}
50-
# {% else %}
51-
# {%- if dbh.oracle_home is defined -%}
52-
# .profile_{{ dbh.oracle_home |basename}}_{{ dbh.oracle_version_db}}
53-
# {%- elif dbh.home is defined -%}
54-
# .profile_{{ dbh.home }}_{{dbh.oracle_version_db}}
55-
# {%- else -%}
56-
# .profile_{{dbh.home}}_{{dbh.oracle_db_name}}
57-
# {%- endif -%}
58-
# {%- endif -%}" # Name of profile-file. Sets up the environment for that ORACLE_HOME
5927
oracle_hostname: "{{ ansible_fqdn }}" # Full (FQDN) name of the host
6028
www_download_bin: curl # curl (shell module) or get_url module
6129

roles/oraswdb_install/tasks/19.3.0.0.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
- name: install_home_db | Install Oracle Database Server
3-
ansible.builtin.shell: "{{ oracle_home_db }}/runInstaller -responseFile {{ oracle_rsp_stage }}/{{ oracle_db_responsefile }} -ignorePrereq -silent -waitforcompletion"
4-
# noqa command-instead-of-shell
3+
ansible.builtin.command: "{{ oracle_home_db }}/runInstaller -responseFile {{ oracle_rsp_stage }}/{{ oracle_db_responsefile }} -ignorePrereq -silent -waitforcompletion {% if db_homes_config[dbh.home]['oracle_home_name'] is defined %}ORACLE_HOME_NAME={{ db_homes_config[dbh.home]['oracle_home_name'] }}{% endif %}"
54
become: true
65
become_user: "{{ oracle_user }}"
76
run_once: "{{ configure_cluster }}"
@@ -19,3 +18,5 @@
1918
tags:
2019
- oradbinstall
2120
ignore_errors: true
21+
22+
- include_tasks: roohctl.yml

roles/oraswdb_install/tasks/21.3.0.0.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
- name: install_home_db | Install Oracle Database Server
3-
ansible.builtin.shell: "{{ oracle_home_db }}/runInstaller -responseFile {{ oracle_rsp_stage }}/{{ oracle_db_responsefile }} -ignorePrereq -silent -waitforcompletion"
4-
# noqa command-instead-of-shell
3+
ansible.builtin.command: "{{ oracle_home_db }}/runInstaller -responseFile {{ oracle_rsp_stage }}/{{ oracle_db_responsefile }} -ignorePrereq -silent -waitforcompletion {% if db_homes_config[dbh.home]['oracle_home_name'] is defined %}ORACLE_HOME_NAME={{ db_homes_config[dbh.home]['oracle_home_name'] }}{% endif %}"
54
become: true
65
become_user: "{{ oracle_user }}"
76
run_once: "{{ configure_cluster }}"
@@ -19,3 +18,5 @@
1918
tags:
2019
- oradbinstall
2120
ignore_errors: true
21+
22+
- include_tasks: roohctl.yml
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# we need a known value for ORACLE_HOME_NAME for later usage in ansible-oracle
3+
- name: install_home_db | Check Inventory for enabled readonly home
4+
ansible.builtin.assert:
5+
fail_msg: Missing oracle_home_name key in db_homes_config for enabled readonly_home
6+
that:
7+
- db_homes_config[dbh.home]['oracle_home_name'] is defined
8+
when:
9+
- db_homes_config[dbh.home]['readonly_home'] | default(false)
10+
11+
- name: install_home_db | Configure Read Only Oracle Home
12+
ansible.builtin.command: "{{ oracle_home_db }}/bin/roohctl {% if db_homes_config[dbh.home]['readonly_home'] | default(false) %}-enable{% else %}-disable{% endif %}"
13+
become: true
14+
become_user: "{{ oracle_user }}"
15+
run_once: "{{ configure_cluster }}"
16+
when:
17+
- oracle_home_db not in existing_dbhome.stdout_lines
18+
tags:
19+
- roohctl
20+
register: roohctl
21+
failed_when: roohctl.rc not in [0]
22+
23+
- ansible.builtin.debug: var=roohctl.stdout_lines
24+
# noqa unnamed-task ignore-errors
25+
run_once: "{{ configure_cluster }}"
26+
when:
27+
- oracle_home_db not in existing_dbhome.stdout_lines
28+
- roohctl.changed
29+
tags:
30+
- roohctl
31+
ignore_errors: true

0 commit comments

Comments
 (0)