-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Rendanic/prlistener2
oradb-manage-db: Support for listener.ora, sqlnet.ora and tnsnames.ora with new inventory structure
- Loading branch information
Showing
10 changed files
with
344 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
# Information for listener configuration | ||
The following special configurations for | ||
listener are currently supported for | ||
installations without Oracle Restart or | ||
Grid Infraststructure. | ||
|
||
# Requirements | ||
|
||
- only supported with new home structure | ||
- 'listener_installed' and 'oracle_listeners_config' are needed | ||
- multiple Hosts/Ports for each Listener | ||
- Extproc support | ||
- only Database in Filesystem without Restart/Grid Infrastructure is supported at the moment | ||
- Definition of listener_installed disables old functionality | ||
- listener_name in oracle_database for SID_LIST_ in listener.ora | ||
When listener_name in oracle_database is defined a static entry for the instance is added to SID_LIST_ in Listener. | ||
- An Instance could only be part of 1 SID_LIST_ in the Listener | ||
- Don't forget local_listener in init.ora! | ||
- address in oracle_listeners_config need protocol for a host | ||
- listener_port in oracle_database is ignored! | ||
|
||
|
||
# Example Configuration | ||
``` | ||
oracle_listeners_config: | ||
LISTENER: | ||
home: 18300-base | ||
address: | ||
- host: hwe2018 | ||
port: 1521 | ||
protocol: TCP | ||
LISTENER1523: | ||
home: 18300-base | ||
address: | ||
- host: hwe2018 | ||
port: 1523 | ||
protocol: TCP | ||
listener_installed: | ||
- home: 18300-base | ||
listener_name: LISTENER | ||
state: present | ||
- home: 18300-base | ||
listener_name: LISTENER1523 | ||
state: present | ||
oracle_databases: | ||
- home: 18300-base | ||
oracle_db_name: cdb183 | ||
listener_name: LISTENER | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- debug: msg="ORACLE_HOME {{listener_home}}" | ||
tags: listener2 | ||
|
||
- name: listener | create custom configuration in listener.ora | ||
blockinfile: | ||
path: "{{ listener_home }}/network/admin/listener.ora" | ||
backup: True | ||
create: True | ||
group: "{{ oracle_group }}" | ||
owner: "{{ oracle_user }}" | ||
state: present | ||
insertafter: "EOF" | ||
marker: "# {mark} Ansible managed for {{ lsnrinst.listener_name }}" | ||
block: "{{ lookup('template', 'listener_details.j2') }}" | ||
tags: listener2 | ||
|
||
# Don't try to stop the listener at this point | ||
# => Restart of role will fail at create/manage database due to TNS-12514 | ||
- name: listener | Start Listener - ignore errors for running Listener | ||
shell: "export PATH=${ORACLE_HOME}/bin:${PATH}; lsnrctl start {{ lsnrinst.listener_name }} /dev/null; exit 0" | ||
environment: "{{ oracle_env_lsnrctl }}" | ||
become_user: "{{ oracle_user }}" | ||
tags: listener2 | ||
|
||
- name: listener | Reload Listener | ||
shell: "export PATH=${ORACLE_HOME}/bin:${PATH}; lsnrctl reload {{ lsnrinst.listener_name }}" | ||
environment: "{{ oracle_env_lsnrctl }}" | ||
become_user: "{{ oracle_user }}" | ||
tags: listener2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
- debug: msg="sqlnet in ORACLE_HOME {{listener_home}}" | ||
tags: sqlnet2 | ||
|
||
- name: sqlnet.ora | create IFILE entry in sqlnet.ora | ||
lineinfile: | ||
line: "IFILE={{ listener_home }}/network/admin/sqlnet_ansible.ora" | ||
regexp: "^IFILE=/" | ||
insertbefore: BOF | ||
path: "{{ listener_home }}/network/admin/sqlnet.ora" | ||
backup: True | ||
create: True | ||
group: "{{ oracle_group }}" | ||
owner: "{{ oracle_user }}" | ||
state: present | ||
mode: 0644 | ||
tags: sqlnet2 | ||
|
||
- name: sqlnet.ora | create custom configuration in sqlnet_ansible.ora | ||
lineinfile: | ||
path: "{{ listener_home }}/network/admin/sqlnet_ansible.ora" | ||
line: "{{ item.name}}={{item.value }}" | ||
regexp: "^{{ item.name }}=" | ||
backup: True | ||
create: True | ||
group: "{{ oracle_group }}" | ||
owner: "{{ oracle_user }}" | ||
state: present | ||
mode: 0644 | ||
with_items: | ||
- "{{ sqlnet_config[sqlnetinst.sqlnet] }}" | ||
tags: sqlnet2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
- debug: msg="ORACLE_HOME {{listener_home}}" | ||
tags: tnsnames | ||
|
||
- name: tnsnames.ora | create IFILE entry in tnsnames.ora | ||
lineinfile: | ||
line: "IFILE={{ listener_home }}/network/admin/tnsnames_ansible.ora" | ||
regexp: "^IFILE=/" | ||
insertbefore: BOF | ||
path: "{{ listener_home }}/network/admin/tnsnames.ora" | ||
backup: True | ||
create: True | ||
group: "{{ oracle_group }}" | ||
owner: "{{ oracle_user }}" | ||
state: present | ||
mode: 0644 | ||
tags: tnsnames | ||
|
||
- name: tnsnames.ora | create custom configuration in tnsnames_ansible.ora | ||
blockinfile: | ||
path: "{{ listener_home }}/network/admin/tnsnames_ansible.ora" | ||
backup: True | ||
create: True | ||
group: "{{ oracle_group }}" | ||
owner: "{{ oracle_user }}" | ||
state: present | ||
mode: 0644 | ||
insertafter: "EOF" | ||
marker: "# {mark} Ansible managed for {{ tnsinst.tnsname }}" | ||
block: "{{ lookup('template', 'tnsnames' + oracle_tnsnames_config[tnsinst.tnsname]['tnstemplate'] | default('') + '.ora.j2') }}" | ||
tags: tnsnames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
# do not edit the configuration manually. | ||
# The execution of ansible-oracle automatically replace all manual changes! | ||
{{ lsnrinst.listener_name }} = | ||
(DESCRIPTION = | ||
{% if oracle_listeners_config[lsnrinst.listener_name]['address'] is defined %} | ||
(ADDRESS_LIST= | ||
{%- for item in oracle_listeners_config[lsnrinst.listener_name]['address'] %} | ||
{%- if item.host is defined %} | ||
|
||
(ADDRESS = (PROTOCOL = {{ item.protocol | default('TCP') }})(HOST = {{item.host}})(PORT = {{item.port | default(listener_port) }})) | ||
{%- elif item.key is defined %} | ||
(ADDRESS = (PROTOCOL = {{ item.protocol | default('IPC') }})(KEY = {{ item.key }})) | ||
{%- endif %} | ||
{%- endfor %} | ||
|
||
) | ||
) | ||
{%- else %} | ||
(ADDRESS = (PROTOCOL = TCP)(HOST = {{ ansible_host }})(PORT = {{ item.host}})(PORT = {{item.port | default(listener_port) }})) | ||
) | ||
{%- endif %} | ||
|
||
{# config_sid_list is used as a helper. jinja2 doesn't allow the exposing of variables from inside a loop to outside before version 2.10! #} | ||
{%- set config_sid_list = 0 %} | ||
{# The following loop is executed only once for the header 'SID_LIST_... #} | ||
{%- for testsid in oracle_databases if testsid.listener_name is defined and testsid.listener_name == lsnrinst.listener_name and config_sid_list == 0 %} | ||
{%- set config_sid_list = 1 %} | ||
|
||
SID_LIST_{{ lsnrinst.listener_name }} = | ||
{# loop over oracle_database when testsid.listener_name was found for lsnrinst.listener_name #} | ||
{%- for sid in oracle_databases if sid.listener_name is defined and sid.listener_name == lsnrinst.listener_name %} | ||
{%- set sid_name = sid.oracle_db_instance_name | default(sid.oracle_db_name) %} | ||
{%- set sid_name_dgmgrl = sid.oracle_db_unique_name | default(sid.oracle_db_name) %} | ||
(SID_LIST = | ||
(SID_DESC = | ||
{% if db_homes_config[sid.home]['oracle_home'] is defined %} | ||
(ORACLE_HOME = {{db_homes_config[sid.home]['oracle_home']}}) | ||
{% else %} | ||
(ORACLE_HOME = {{oracle_base}}/{{db_homes_config[sid.home]['version']}}/{{db_homes_config[sid.home]['home']}}) | ||
{% endif %} | ||
(SID_NAME = {{ sid_name }}) | ||
) | ||
{# added for compatibility against Oracle 11.2#} | ||
(SID_DESC = | ||
{% if db_homes_config[sid.home]['oracle_home'] is defined %} | ||
(ORACLE_HOME = {{db_homes_config[sid.home]['oracle_home']}}) | ||
{% else %} | ||
(ORACLE_HOME = {{oracle_base}}/{{db_homes_config[sid.home]['version']}}/{{db_homes_config[sid.home]['home']}}) | ||
{% endif %} | ||
(SID_NAME = {{ sid_name }}) | ||
(GLOBAL_DBNAME = {{ sid_name_dgmgrl }}_DGMGRL) | ||
) | ||
{% endfor %} | ||
) | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{# | ||
https://www.oracle.com/technetwork/database/availability/client-failover-2280805.pdf | ||
SALES= | ||
(DESCRIPTION= | ||
(FAILOVER=on) | ||
(CONNECT_TIMEOUT=5)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=3) | ||
(ADDRESS_LIST= | ||
(LOAD_BALANCE=on) | ||
(ADDRESS=(PROTOCOL=TCP)(HOST=prmy-scan)(PORT=1521)) | ||
(ADDRESS=(PROTOCOL=TCP)(HOST=stby-scan)(PORT=1521)) | ||
) | ||
(CONNECT_DATA=(SERVICE_NAME=oltpworkload)) | ||
) | ||
#} | ||
|
||
# do not edit the configuration manually. | ||
# The execution of ansible-oracle automatically replace all manual changes! | ||
{{ tnsinst.tnsname | upper }} = | ||
(DESCRIPTION = | ||
(FAILOVER={{ oracle_tnsnames_config[tnsinst.tnsname]['failover'] | default('yes')}}) | ||
(CONNECT_TIMEOUT={{ oracle_tnsnames_config[tnsinst.tnsname]['connect_timeout'] | default('5')}}) | ||
(TRANSPORT_CONNECT_TIMEOUT={{ oracle_tnsnames_config[tnsinst.tnsname]['transport_connect_timeout'] | default('3')}}) | ||
(RETRY_COUNT={{ oracle_tnsnames_config[tnsinst.tnsname]['retry_count'] | default('3')}}) | ||
(ADDRESS_LIST = | ||
(LOAD_BALANCE={{ oracle_tnsnames_config[tnsinst.tnsname]['load_balance'] | default('on')}}) | ||
{% for addr in oracle_tnsnames_config[tnsinst.tnsname]['address'] %} | ||
(ADDRESS = (PROTOCOL = {{addr.tcp | default ('TCP')}})(Host = {{addr.host}})(Port = {{addr.port | default(listener_port) }})) | ||
{% endfor %} | ||
) | ||
(CONNECT_DATA = | ||
{%- if oracle_tnsnames_config[tnsinst.tnsname]['connect'] is defined %} | ||
{%- if oracle_tnsnames_config[tnsinst.tnsname]['connect']['service_name'] is defined %} | ||
|
||
(SERVICE_NAME = {{oracle_tnsnames_config[tnsinst.tnsname]['connect']['service_name']}}) | ||
{%- elif oracle_tnsnames_config[tnsinst.tnsname]['connect']['sid_name'] is defined %} | ||
|
||
(SID = {{oracle_tnsnames_config[tnsinst.tnsname]['connect']['sid_name']}}) | ||
{%- endif %} | ||
{%- endif %} | ||
|
||
(SERVER = {{oracle_tnsnames_config[tnsinst.tnsname]['connect']['SERVER']| default ('DEDICATED')}}) | ||
) | ||
) |
53 changes: 53 additions & 0 deletions
53
roles/oradb-manage-db/templates/tnsnamesdgfailover2.ora.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{# | ||
https://www.oracle.com/technetwork/database/availability/client-failover-2280805.pdf | ||
SALES= | ||
(DESCRIPTION_LIST= | ||
(LOAD_BALANCE=off) | ||
(FAILOVER=on) | ||
(DESCRIPTION= | ||
(CONNECT_TIMEOUT=5) | ||
(TRANSPORT_CONNECT_TIMEOUT=3) | ||
(RETRY_COUNT=3) | ||
(ADDRESS_LIST= | ||
(LOAD_BALANCE=on) | ||
(ADDRESS=(PROTOCOL=TCP)(HOST=prmy-scan)(PORT=1521)) | ||
) | ||
(CONNECT_DATA=(SERVICE_NAME=oltpworkload)) | ||
) | ||
(DESCRIPTION= | ||
(CONNECT_TIMEOUT=5) | ||
(TRANSPORT_CONNECT_TIMEOUT=3) | ||
(RETRY_COUNT=3) | ||
(ADDRESS_LIST= | ||
(LOAD_BALANCE=on) | ||
(ADDRESS=(PROTOCOL=TCP)(HOST=stby-scan)(PORT=1521)) | ||
) | ||
(CONNECT_DATA=(SERVICE_NAME=oltpworkload)) | ||
) | ||
) | ||
#} | ||
|
||
# do not edit the configuration manually. | ||
# The execution of ansible-oracle automatically replace all manual changes! | ||
{{ tnsinst.tnsname | upper }} = | ||
(DESCRIPTION_LIST= | ||
(LOAD_BALANCE={{ oracle_tnsnames_config[tnsinst.tnsname]['load_balance'] | default('off')}}) | ||
(FAILOVER={{ oracle_tnsnames_config[tnsinst.tnsname]['failover'] | default('yes')}}) | ||
{% for addr in oracle_tnsnames_config[tnsinst.tnsname]['address'] %} | ||
(DESCRIPTION= | ||
(CONNECT_TIMEOUT={{ oracle_tnsnames_config[tnsinst.tnsname]['connect_timeout'] | default('5')}}) | ||
(TRANSPORT_CONNECT_TIMEOUT={{ oracle_tnsnames_config[tnsinst.tnsname]['transport_connect_timeout'] | default('3')}}) | ||
(RETRY_COUNT={{ oracle_tnsnames_config[tnsinst.tnsname]['retry_count'] | default('3')}}) | ||
(ADDRESS_LIST= | ||
(LOAD_BALANCE={{ oracle_tnsnames_config[tnsinst.tnsname]['load_balance'] | default('on')}}) | ||
(ADDRESS = (PROTOCOL = {{addr.tcp | default ('TCP')}})(Host = {{addr.host}})(Port = {{addr.port | default(listener_port) }})) | ||
) | ||
(CONNECT_DATA = | ||
(SERVICE_NAME = {{oracle_tnsnames_config[tnsinst.tnsname]['connect']['service_name']}}) | ||
(SERVER = {{oracle_tnsnames_config[tnsinst.tnsname]['connect']['SERVER']| default ('DEDICATED')}}) | ||
) | ||
) | ||
{% endfor %} | ||
) |