Debian Codegraph @

test/integration/targets/blockinfile/tasks/multiline_search.yml

raw
1 - name: Create multiline_search test file
2 copy:
3 dest: "{{ remote_tmp_dir }}/listener.ora"
4 content: |
5 LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
6 ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
7
8 SID_LIST_LISTENER_DG =
9 (SID_LIST =
10 (SID_DESC =
11 (GLOBAL_DBNAME = DB01_DG)
12 (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1)
13 (SID_NAME = DB011)
14 )
15 )
16
17 SID_LIST_LISTENER =
18 (SID_LIST =
19 (SID_DESC =
20 (GLOBAL_DBNAME = DB02)
21 (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1)
22 (SID_NAME = DB021)
23 )
24 )
25
26 - name: Set fact listener_line
27 set_fact:
28 listener_line: |
29 (SID_DESC =
30 (GLOBAL_DBNAME = DB03
31 (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1)
32 (SID_NAME = DB031)
33 )
34
35 - name: Add block using multiline_search enabled
36 blockinfile:
37 path: "{{ remote_tmp_dir }}/listener.ora"
38 block: "{{ listener_line }}"
39 insertafter: '(?m)SID_LIST_LISTENER_DG =\n.*\(SID_LIST ='
40 marker: " <!-- {mark} ANSIBLE MANAGED BLOCK 1-->"
41 register: multiline_search1
42
43 - name: Add block using multiline_search enabled again
44 blockinfile:
45 path: "{{ remote_tmp_dir }}/listener.ora"
46 block: "{{ listener_line }}"
47 insertafter: '(?m)SID_LIST_LISTENER_DG =\n.*\(SID_LIST ='
48 marker: " <!-- {mark} ANSIBLE MANAGED BLOCK 1-->"
49 register: multiline_search2
50
51 - name: Try to add block using without multiline flag in regex should add block add end of file
52 blockinfile:
53 path: "{{ remote_tmp_dir }}/listener.ora"
54 block: "{{ listener_line }}"
55 insertafter: 'SID_LIST_LISTENER_DG =\n.*\(SID_LIST ='
56 marker: " <!-- {mark} ANSIBLE MANAGED BLOCK 2-->"
57 register: multiline_search3
58
59 - name: Stat the listener.ora file
60 stat:
61 path: "{{ remote_tmp_dir }}/listener.ora"
62 register: listener_ora_file
63
64 - name: Ensure insertafter worked correctly
65 assert:
66 that:
67 - multiline_search1 is changed
68 - multiline_search2 is not changed
69 - multiline_search3 is changed
70 - listener_ora_file.stat.checksum == '5a8010ac4a2fad7c822e6aeb276931657cee75c0'