Skip to content

Commit b2c1de7

Browse files
committed
oradb_manage_db: allow multiline values for keys in sqlnet_ansible.ora
1 parent b4f4e47 commit b2c1de7

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
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+
- "oradb_manage_db: allow multiline values for keys in sqlnet_ansible.ora ()"

roles/oradb_manage_db/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ oracle_gi_cluster_type: STANDARD
100100
101101
**_sql_script_**
102102
103+
**_sqlnet_**
104+
103105
**_sqlnet2_**
104106
105107
**_tnsnames_**

roles/oradb_manage_db/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
loop_var: sqlnetinst
3434
when: sqlnet_installed is defined
3535
tags: sqlnet2
36+
vars:
37+
_sqlnet_ansible_file: "{{ _oradb_manage_db_tns_home }}/network/admin/sqlnet_ansible.ora"
3638

3739
- name: manage_db | include listener_details.yml
3840
ansible.builtin.include_tasks: listener_details.yml

roles/oradb_manage_db/tasks/sqlnet.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,50 @@
1717
mode: 0644
1818
tags: sqlnet2
1919

20+
# Important!
21+
# ansible-oracle <= 4.3 used lineinfile instead blockinfile with marker
22+
# => Remove old entries before readding them with blockinfile
23+
- name: Check for existing sqlnet_ansible.ora
24+
ansible.builtin.stat:
25+
path: "{{ _sqlnet_ansible_file }}"
26+
register: _sqlnet_ansible_file_res
27+
tags:
28+
- sqlnet
29+
- sqlnet2
30+
31+
- name: Working on sqlnet_ansible.ora
32+
tags:
33+
- sqlnet
34+
- sqlnet2
35+
when:
36+
- _sqlnet_ansible_file_res.stat.exists
37+
block:
38+
- name: Search for marker in sqlnet_ansible.ora
39+
ansible.builtin.lineinfile:
40+
path: "{{ _sqlnet_ansible_file }}"
41+
regexp: "# BEGIN Ansible managed for .*"
42+
line: "# BEGIN Ansible managed for .*"
43+
state: present
44+
register: old_sqlnet_ansible_res
45+
changed_when: false
46+
check_mode: true
47+
48+
# Remove existing sqlnet_ansible.ora when no new marker is in place
49+
# => we found an old configuration file created with lineinfile
50+
# this must be changed to blockinfile with marker
51+
- name: Remove existing sqlnet_ansible.ora due to missing new marker items
52+
ansible.builtin.file:
53+
path: "{{ _sqlnet_ansible_file }}"
54+
state: absent
55+
when: "'line added' in old_sqlnet_ansible_res.msg"
56+
2057
- name: sqlnet.ora | create custom configuration in sqlnet_ansible.ora
21-
ansible.builtin.lineinfile:
22-
path: "{{ _oradb_manage_db_tns_home }}/network/admin/sqlnet_ansible.ora"
23-
line: "{{ item.name }}={{ item.value }}"
24-
regexp: "^{{ item.name }}="
58+
ansible.builtin.blockinfile:
59+
path: "{{ _sqlnet_ansible_file }}"
60+
block: >-
61+
{{ sc_loop.name }} = {{ sc_loop.value }}
62+
marker: "# {mark} Ansible managed for {{ sc_loop.name }}"
63+
insertafter: "EOF"
2564
backup: true
2665
create: true
2766
group: "{{ oracle_group }}"
@@ -30,4 +69,9 @@
3069
mode: 0644
3170
with_items:
3271
- "{{ sqlnet_config[sqlnetinst.sqlnet] }}"
72+
loop_control:
73+
label: >-
74+
{{ sqlnetinst.sqlnet }}
75+
{{ sc_loop.name }}
76+
loop_var: sc_loop
3377
tags: sqlnet2

0 commit comments

Comments
 (0)