|
17 | 17 | mode: 0644 |
18 | 18 | tags: sqlnet2 |
19 | 19 |
|
| 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 | + |
20 | 57 | - 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" |
25 | 64 | backup: true |
26 | 65 | create: true |
27 | 66 | group: "{{ oracle_group }}" |
|
30 | 69 | mode: 0644 |
31 | 70 | with_items: |
32 | 71 | - "{{ sqlnet_config[sqlnetinst.sqlnet] }}" |
| 72 | + loop_control: |
| 73 | + label: >- |
| 74 | + {{ sqlnetinst.sqlnet }} |
| 75 | + {{ sc_loop.name }} |
| 76 | + loop_var: sc_loop |
33 | 77 | tags: sqlnet2 |
0 commit comments