From 8a754e0858d922e955e71b253c139e071ecec432 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 18:04:21 +0200 Subject: Adding upstream version 2.14.3. Signed-off-by: Daniel Baumann --- .../targets/blockinfile/tasks/multiline_search.yml | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/integration/targets/blockinfile/tasks/multiline_search.yml (limited to 'test/integration/targets/blockinfile/tasks/multiline_search.yml') diff --git a/test/integration/targets/blockinfile/tasks/multiline_search.yml b/test/integration/targets/blockinfile/tasks/multiline_search.yml new file mode 100644 index 0000000..8eb94f5 --- /dev/null +++ b/test/integration/targets/blockinfile/tasks/multiline_search.yml @@ -0,0 +1,70 @@ +- name: Create multiline_search test file + copy: + dest: "{{ remote_tmp_dir }}/listener.ora" + content: | + LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent + ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent + + SID_LIST_LISTENER_DG = + (SID_LIST = + (SID_DESC = + (GLOBAL_DBNAME = DB01_DG) + (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1) + (SID_NAME = DB011) + ) + ) + + SID_LIST_LISTENER = + (SID_LIST = + (SID_DESC = + (GLOBAL_DBNAME = DB02) + (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1) + (SID_NAME = DB021) + ) + ) + +- name: Set fact listener_line + set_fact: + listener_line: | + (SID_DESC = + (GLOBAL_DBNAME = DB03 + (ORACLE_HOME = /u01/app/oracle/product/12.1.0.1/db_1) + (SID_NAME = DB031) + ) + +- name: Add block using multiline_search enabled + blockinfile: + path: "{{ remote_tmp_dir }}/listener.ora" + block: "{{ listener_line }}" + insertafter: '(?m)SID_LIST_LISTENER_DG =\n.*\(SID_LIST =' + marker: " " + register: multiline_search1 + +- name: Add block using multiline_search enabled again + blockinfile: + path: "{{ remote_tmp_dir }}/listener.ora" + block: "{{ listener_line }}" + insertafter: '(?m)SID_LIST_LISTENER_DG =\n.*\(SID_LIST =' + marker: " " + register: multiline_search2 + +- name: Try to add block using without multiline flag in regex should add block add end of file + blockinfile: + path: "{{ remote_tmp_dir }}/listener.ora" + block: "{{ listener_line }}" + insertafter: 'SID_LIST_LISTENER_DG =\n.*\(SID_LIST =' + marker: " " + register: multiline_search3 + +- name: Stat the listener.ora file + stat: + path: "{{ remote_tmp_dir }}/listener.ora" + register: listener_ora_file + +- name: Ensure insertafter worked correctly + assert: + that: + - multiline_search1 is changed + - multiline_search2 is not changed + - multiline_search3 is changed + - listener_ora_file.stat.checksum == '5a8010ac4a2fad7c822e6aeb276931657cee75c0' -- cgit v1.2.3