Fix lineinfile test (#75785)

* fix remote test after controller split

* other files had it too!
pull/75793/head
Brian Coca 3 years ago committed by GitHub
parent 0d5a9f2138
commit a22964609e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,3 +18,4 @@
dependencies: dependencies:
- prepare_tests - prepare_tests
- setup_remote_tmp_dir

@ -19,7 +19,7 @@
- name: deploy the test file for lineinfile - name: deploy the test file for lineinfile
copy: copy:
src: test.txt src: test.txt
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert that the test file was deployed - name: assert that the test file was deployed
@ -31,7 +31,7 @@
- name: "create a file that does not yet exist with `create: yes` and produce diff" - name: "create a file that does not yet exist with `create: yes` and produce diff"
lineinfile: lineinfile:
dest: "{{ output_dir }}/a/a.txt" dest: "{{ remote_tmp_dir }}/a/a.txt"
state: present state: present
line: "First line" line: "First line"
create: yes create: yes
@ -45,7 +45,7 @@
- name: stat the new file - name: stat the new file
stat: stat:
path: "{{ output_dir }}/a/a.txt" path: "{{ remote_tmp_dir }}/a/a.txt"
register: result register: result
- name: assert that the file exists - name: assert that the file exists
@ -70,7 +70,7 @@
- block: - block:
- name: EXPECTED FAILURE - test invalid `validate` value - name: EXPECTED FAILURE - test invalid `validate` value
lineinfile: lineinfile:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "Doesn't matter" line: "Doesn't matter"
validate: '/some/path' validate: '/some/path'
@ -84,7 +84,7 @@
- name: insert a line at the beginning of the file, and back it up - name: insert a line at the beginning of the file, and back it up
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New line at the beginning" line: "New line at the beginning"
insertbefore: "BOF" insertbefore: "BOF"
@ -93,7 +93,7 @@
- name: insert a line at the beginning of the file again - name: insert a line at the beginning of the file again
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New line at the beginning" line: "New line at the beginning"
insertbefore: "BOF" insertbefore: "BOF"
@ -119,7 +119,7 @@
- name: stat the test after the insert at the head - name: stat the test after the insert at the head
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test hash is what we expect for the file with the insert at the head - name: assert test hash is what we expect for the file with the insert at the head
@ -129,7 +129,7 @@
- name: insert a line at the end of the file - name: insert a line at the end of the file
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New line at the end" line: "New line at the end"
insertafter: "EOF" insertafter: "EOF"
@ -143,7 +143,7 @@
- name: stat the test after the insert at the end - name: stat the test after the insert at the end
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after the insert at the end - name: assert test checksum matches after the insert at the end
@ -153,7 +153,7 @@
- name: insert a line after the first line - name: insert a line after the first line
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New line after line 1" line: "New line after line 1"
insertafter: "^This is line 1$" insertafter: "^This is line 1$"
@ -167,7 +167,7 @@
- name: stat the test after insert after the first line - name: stat the test after insert after the first line
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after the insert after the first line - name: assert test checksum matches after the insert after the first line
@ -177,7 +177,7 @@
- name: insert a line before the last line - name: insert a line before the last line
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New line before line 5" line: "New line before line 5"
insertbefore: "^This is line 5$" insertbefore: "^This is line 5$"
@ -191,7 +191,7 @@
- name: stat the test after the insert before the last line - name: stat the test after the insert before the last line
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after the insert before the last line - name: assert test checksum matches after the insert before the last line
@ -201,7 +201,7 @@
- name: Replace a line with backrefs - name: Replace a line with backrefs
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "This is line 3" line: "This is line 3"
backrefs: yes backrefs: yes
@ -210,13 +210,13 @@
- name: Replace a line with backrefs again - name: Replace a line with backrefs again
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "This is line 3" line: "This is line 3"
backrefs: yes backrefs: yes
regexp: "^(REF) .* \\1$" regexp: "^(REF) .* \\1$"
register: backrefs_result2 register: backrefs_result2
- command: cat {{ output_dir }}/test.txt - command: cat {{ remote_tmp_dir }}/test.txt
- name: assert that the line with backrefs was changed - name: assert that the line with backrefs was changed
assert: assert:
@ -227,7 +227,7 @@
- name: stat the test after the backref line was replaced - name: stat the test after the backref line was replaced
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -237,7 +237,7 @@
- name: remove the middle line - name: remove the middle line
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: absent state: absent
regexp: "^This is line 3$" regexp: "^This is line 3$"
register: result register: result
@ -250,7 +250,7 @@
- name: stat the test after the middle line was removed - name: stat the test after the middle line was removed
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after the middle line was removed - name: assert test checksum matches after the middle line was removed
@ -260,7 +260,7 @@
- name: run a validation script that succeeds - name: run a validation script that succeeds
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: absent state: absent
regexp: "^This is line 5$" regexp: "^This is line 5$"
validate: "true %s" validate: "true %s"
@ -274,7 +274,7 @@
- name: stat the test after the validation succeeded - name: stat the test after the validation succeeded
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after the validation succeeded - name: assert test checksum matches after the validation succeeded
@ -284,7 +284,7 @@
- name: run a validation script that fails - name: run a validation script that fails
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: absent state: absent
regexp: "^This is line 1$" regexp: "^This is line 1$"
validate: "/bin/false %s" validate: "/bin/false %s"
@ -298,7 +298,7 @@
- name: stat the test after the validation failed - name: stat the test after the validation failed
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches the previous after the validation failed - name: assert test checksum matches the previous after the validation failed
@ -310,7 +310,7 @@
- name: use create=yes - name: use create=yes
lineinfile: lineinfile:
dest: "{{ output_dir }}/new_test.txt" dest: "{{ remote_tmp_dir }}/new_test.txt"
create: yes create: yes
insertbefore: BOF insertbefore: BOF
state: present state: present
@ -325,7 +325,7 @@
- name: validate that the newly created file exists - name: validate that the newly created file exists
stat: stat:
path: "{{ output_dir }}/new_test.txt" path: "{{ remote_tmp_dir }}/new_test.txt"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -356,12 +356,12 @@
- name: testnoeof deploy the file for lineinfile - name: testnoeof deploy the file for lineinfile
copy: copy:
src: testnoeof.txt src: testnoeof.txt
dest: "{{ output_dir }}/testnoeof.txt" dest: "{{ remote_tmp_dir }}/testnoeof.txt"
register: result register: result
- name: testnoeof insert a line at the end of the file - name: testnoeof insert a line at the end of the file
lineinfile: lineinfile:
dest: "{{ output_dir }}/testnoeof.txt" dest: "{{ remote_tmp_dir }}/testnoeof.txt"
state: present state: present
line: "New line at the end" line: "New line at the end"
insertafter: "EOF" insertafter: "EOF"
@ -375,7 +375,7 @@
- name: insert a multiple lines at the end of the file - name: insert a multiple lines at the end of the file
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "This is a line\nwith \\n character" line: "This is a line\nwith \\n character"
insertafter: "EOF" insertafter: "EOF"
@ -389,7 +389,7 @@
- name: testnoeof stat the no newline EOF test after the insert at the end - name: testnoeof stat the no newline EOF test after the insert at the end
stat: stat:
path: "{{ output_dir }}/testnoeof.txt" path: "{{ remote_tmp_dir }}/testnoeof.txt"
register: result register: result
- name: testnoeof assert test checksum matches after the insert at the end - name: testnoeof assert test checksum matches after the insert at the end
@ -401,12 +401,12 @@
- name: testempty deploy the testempty file for lineinfile - name: testempty deploy the testempty file for lineinfile
copy: copy:
src: testempty.txt src: testempty.txt
dest: "{{ output_dir }}/testempty.txt" dest: "{{ remote_tmp_dir }}/testempty.txt"
register: result register: result
- name: testempty insert a line at the end of the file - name: testempty insert a line at the end of the file
lineinfile: lineinfile:
dest: "{{ output_dir }}/testempty.txt" dest: "{{ remote_tmp_dir }}/testempty.txt"
state: present state: present
line: "New line at the end" line: "New line at the end"
insertafter: "EOF" insertafter: "EOF"
@ -420,7 +420,7 @@
- name: testempty stat the test after the insert at the end - name: testempty stat the test after the insert at the end
stat: stat:
path: "{{ output_dir }}/testempty.txt" path: "{{ remote_tmp_dir }}/testempty.txt"
register: result register: result
- name: testempty assert test checksum matches after the insert at the end - name: testempty assert test checksum matches after the insert at the end
@ -429,7 +429,7 @@
- "result.stat.checksum == 'f440dc65ea9cec3fd496c1479ddf937e1b949412'" - "result.stat.checksum == 'f440dc65ea9cec3fd496c1479ddf937e1b949412'"
- stat: - stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after inserting multiple lines - name: assert test checksum matches after inserting multiple lines
@ -439,7 +439,7 @@
- name: replace a line with backrefs included in the line - name: replace a line with backrefs included in the line
lineinfile: lineinfile:
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
state: present state: present
line: "New \\1 created with the backref" line: "New \\1 created with the backref"
backrefs: yes backrefs: yes
@ -454,7 +454,7 @@
- name: stat the test after the backref line was replaced - name: stat the test after the backref line was replaced
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -467,7 +467,7 @@
- name: create a new file for testing quoting issues - name: create a new file for testing quoting issues
file: file:
dest: "{{ output_dir }}/test_quoting.txt" dest: "{{ remote_tmp_dir }}/test_quoting.txt"
state: touch state: touch
register: result register: result
@ -478,7 +478,7 @@
- name: use with_items to add code-like strings to the quoting txt file - name: use with_items to add code-like strings to the quoting txt file
lineinfile: lineinfile:
dest: "{{ output_dir }}/test_quoting.txt" dest: "{{ remote_tmp_dir }}/test_quoting.txt"
line: "{{ item }}" line: "{{ item }}"
insertbefore: BOF insertbefore: BOF
with_items: with_items:
@ -500,7 +500,7 @@
- name: stat the quote test file - name: stat the quote test file
stat: stat:
path: "{{ output_dir }}/test_quoting.txt" path: "{{ remote_tmp_dir }}/test_quoting.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -510,7 +510,7 @@
- name: insert a line into the quoted file with a single quote - name: insert a line into the quoted file with a single quote
lineinfile: lineinfile:
dest: "{{ output_dir }}/test_quoting.txt" dest: "{{ remote_tmp_dir }}/test_quoting.txt"
line: "import g'" line: "import g'"
register: result register: result
@ -521,7 +521,7 @@
- name: stat the quote test file - name: stat the quote test file
stat: stat:
path: "{{ output_dir }}/test_quoting.txt" path: "{{ remote_tmp_dir }}/test_quoting.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -531,7 +531,7 @@
- name: insert a line into the quoted file with many double quotation strings - name: insert a line into the quoted file with many double quotation strings
lineinfile: lineinfile:
dest: "{{ output_dir }}/test_quoting.txt" dest: "{{ remote_tmp_dir }}/test_quoting.txt"
line: "\"quote\" and \"unquote\"" line: "\"quote\" and \"unquote\""
register: result register: result
@ -542,7 +542,7 @@
- name: stat the quote test file - name: stat the quote test file
stat: stat:
path: "{{ output_dir }}/test_quoting.txt" path: "{{ remote_tmp_dir }}/test_quoting.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -556,7 +556,7 @@
- name: Deploy the testmultiple file - name: Deploy the testmultiple file
copy: copy:
src: testmultiple.txt src: testmultiple.txt
dest: "{{ output_dir }}/testmultiple.txt" dest: "{{ remote_tmp_dir }}/testmultiple.txt"
register: result register: result
- name: Assert that the testmultiple file was deployed - name: Assert that the testmultiple file was deployed
@ -569,7 +569,7 @@
# Test insertafter # Test insertafter
- name: Write the same line to a file inserted after different lines - name: Write the same line to a file inserted after different lines
lineinfile: lineinfile:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
insertafter: "{{ item.regex }}" insertafter: "{{ item.regex }}"
line: "{{ item.replace }}" line: "{{ item.replace }}"
register: _multitest_1 register: _multitest_1
@ -585,7 +585,7 @@
- name: Do the same thing again to check for changes - name: Do the same thing again to check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
insertafter: "{{ item.regex }}" insertafter: "{{ item.regex }}"
line: "{{ item.replace }}" line: "{{ item.replace }}"
register: _multitest_2 register: _multitest_2
@ -601,7 +601,7 @@
- name: Stat the insertafter file - name: Stat the insertafter file
stat: stat:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
register: result register: result
- name: Assert that the insertafter file matches expected checksum - name: Assert that the insertafter file matches expected checksum
@ -614,7 +614,7 @@
- name: Deploy the testmultiple file - name: Deploy the testmultiple file
copy: copy:
src: testmultiple.txt src: testmultiple.txt
dest: "{{ output_dir }}/testmultiple.txt" dest: "{{ remote_tmp_dir }}/testmultiple.txt"
register: result register: result
- name: Assert that the testmultiple file was deployed - name: Assert that the testmultiple file was deployed
@ -626,7 +626,7 @@
- name: Write the same line to a file inserted before different lines - name: Write the same line to a file inserted before different lines
lineinfile: lineinfile:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
insertbefore: "{{ item.regex }}" insertbefore: "{{ item.regex }}"
line: "{{ item.replace }}" line: "{{ item.replace }}"
register: _multitest_3 register: _multitest_3
@ -642,7 +642,7 @@
- name: Do the same thing again to check for changes - name: Do the same thing again to check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
insertbefore: "{{ item.regex }}" insertbefore: "{{ item.regex }}"
line: "{{ item.replace }}" line: "{{ item.replace }}"
register: _multitest_4 register: _multitest_4
@ -658,7 +658,7 @@
- name: Stat the insertbefore file - name: Stat the insertbefore file
stat: stat:
path: "{{ output_dir }}/testmultiple.txt" path: "{{ remote_tmp_dir }}/testmultiple.txt"
register: result register: result
- name: Assert that the insertbefore file matches expected checksum - name: Assert that the insertbefore file matches expected checksum
@ -673,7 +673,7 @@
- name: Deploy the test.conf file - name: Deploy the test.conf file
copy: copy:
src: test.conf src: test.conf
dest: "{{ output_dir }}/test.conf" dest: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the test.conf file was deployed - name: Assert that the test.conf file was deployed
@ -686,7 +686,7 @@
# Test instertafter # Test instertafter
- name: Insert lines after with regexp - name: Insert lines after with regexp
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
@ -695,7 +695,7 @@
- name: Do the same thing again and check for changes - name: Do the same thing again and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
@ -713,7 +713,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -723,7 +723,7 @@
- name: Do the same thing a third time without regexp and check for changes - name: Do the same thing a third time without regexp and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
with_items: "{{ test_befaf_regexp }}" with_items: "{{ test_befaf_regexp }}"
@ -731,7 +731,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file was changed when no regexp was provided - name: Assert that the file was changed when no regexp was provided
@ -742,7 +742,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -754,7 +754,7 @@
- name: Deploy the test.conf file - name: Deploy the test.conf file
copy: copy:
src: test.conf src: test.conf
dest: "{{ output_dir }}/test.conf" dest: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the test.conf file was deployed - name: Assert that the test.conf file was deployed
@ -766,7 +766,7 @@
- name: Insert lines before with regexp - name: Insert lines before with regexp
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
@ -775,7 +775,7 @@
- name: Do the same thing again and check for changes - name: Do the same thing again and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
@ -793,7 +793,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -803,7 +803,7 @@
- name: Do the same thing a third time without regexp and check for changes - name: Do the same thing a third time without regexp and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
with_items: "{{ test_befaf_regexp }}" with_items: "{{ test_befaf_regexp }}"
@ -811,7 +811,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file was changed when no regexp was provided - name: Assert that the file was changed when no regexp was provided
@ -822,7 +822,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.conf" path: "{{ remote_tmp_dir }}/test.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -833,25 +833,25 @@
- name: Copy empty file to test with insertbefore - name: Copy empty file to test with insertbefore
copy: copy:
src: testempty.txt src: testempty.txt
dest: "{{ output_dir }}/testempty.txt" dest: "{{ remote_tmp_dir }}/testempty.txt"
- name: Add a line to empty file with insertbefore - name: Add a line to empty file with insertbefore
lineinfile: lineinfile:
path: "{{ output_dir }}/testempty.txt" path: "{{ remote_tmp_dir }}/testempty.txt"
line: top line: top
insertbefore: '^not in the file$' insertbefore: '^not in the file$'
register: oneline_insbefore_test1 register: oneline_insbefore_test1
- name: Add a line to file with only one line using insertbefore - name: Add a line to file with only one line using insertbefore
lineinfile: lineinfile:
path: "{{ output_dir }}/testempty.txt" path: "{{ remote_tmp_dir }}/testempty.txt"
line: top line: top
insertbefore: '^not in the file$' insertbefore: '^not in the file$'
register: oneline_insbefore_test2 register: oneline_insbefore_test2
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/testempty.txt" path: "{{ remote_tmp_dir }}/testempty.txt"
register: oneline_insbefore_file register: oneline_insbefore_file
- name: Assert that insertebefore worked properly with a one line file - name: Assert that insertebefore worked properly with a one line file
@ -870,7 +870,7 @@
- name: Deploy the test file for lineinfile - name: Deploy the test file for lineinfile
copy: copy:
src: test.txt src: test.txt
dest: "{{ output_dir }}/test.txt" dest: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -882,14 +882,14 @@
- name: Insert a line in the file using an empty string as a regular expression - name: Insert a line in the file using an empty string as a regular expression
lineinfile: lineinfile:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
regexp: '' regexp: ''
line: This is line 6 line: This is line 6
register: insert_empty_regexp register: insert_empty_regexp
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test.txt" path: "{{ remote_tmp_dir }}/test.txt"
register: result register: result
- name: Assert that the file contents match what is expected and a warning was displayed - name: Assert that the file contents match what is expected and a warning was displayed
@ -911,7 +911,7 @@
- name: Deploy the test file for lineinfile - name: Deploy the test file for lineinfile
copy: copy:
src: teststring.txt src: teststring.txt
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -923,14 +923,14 @@
- name: Insert a line in the file using an empty string as a search string - name: Insert a line in the file using an empty string as a search string
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
search_string: '' search_string: ''
line: This is line 6 line: This is line 6
register: insert_empty_literal register: insert_empty_literal
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: Assert that the file contents match what is expected and a warning was displayed - name: Assert that the file contents match what is expected and a warning was displayed
@ -954,7 +954,7 @@
- name: Deploy the firstmatch test file - name: Deploy the firstmatch test file
copy: copy:
src: firstmatch.txt src: firstmatch.txt
dest: "{{ output_dir }}/firstmatch.txt" dest: "{{ remote_tmp_dir }}/firstmatch.txt"
register: result register: result
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -966,7 +966,7 @@
- name: Insert a line before an existing line using firstmatch - name: Insert a line before an existing line using firstmatch
lineinfile: lineinfile:
path: "{{ output_dir }}/firstmatch.txt" path: "{{ remote_tmp_dir }}/firstmatch.txt"
line: INSERT line: INSERT
insertafter: line1 insertafter: line1
firstmatch: yes firstmatch: yes
@ -974,7 +974,7 @@
- name: Insert a line before an existing line using firstmatch again - name: Insert a line before an existing line using firstmatch again
lineinfile: lineinfile:
path: "{{ output_dir }}/firstmatch.txt" path: "{{ remote_tmp_dir }}/firstmatch.txt"
line: INSERT line: INSERT
insertafter: line1 insertafter: line1
firstmatch: yes firstmatch: yes
@ -982,7 +982,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/firstmatch.txt" path: "{{ remote_tmp_dir }}/firstmatch.txt"
register: result register: result
- name: Assert that the file was modified appropriately - name: Assert that the file was modified appropriately
@ -1000,7 +1000,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: test_58923.txt src: test_58923.txt
dest: "{{ output_dir }}/test_58923.txt" dest: "{{ remote_tmp_dir }}/test_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1021,7 +1021,7 @@
# Regexp is not present in the file, so the line must be inserted after ^#!/bin/sh # Regexp is not present in the file, so the line must be inserted after ^#!/bin/sh
- name: Add the line using firstmatch, regexp, and insertafter - name: Add the line using firstmatch, regexp, and insertafter
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
regexp: ^export FISHEYE_OPTS regexp: ^export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1030,12 +1030,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertafter_test1_file register: insertafter_test1_file
- name: Add the line using firstmatch, regexp, and insertafter again - name: Add the line using firstmatch, regexp, and insertafter again
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
regexp: ^export FISHEYE_OPTS regexp: ^export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1047,7 +1047,7 @@
# so nothing has been added: # so nothing has been added:
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertafter_test2_file register: insertafter_test2_file
- name: Assert insertafter tests gave the expected results - name: Assert insertafter tests gave the expected results
@ -1062,7 +1062,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: test_58923.txt src: test_58923.txt
dest: "{{ output_dir }}/test_58923.txt" dest: "{{ remote_tmp_dir }}/test_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1074,7 +1074,7 @@
- name: Insert the line using firstmatch and insertafter without regexp - name: Insert the line using firstmatch and insertafter without regexp
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
firstmatch: true firstmatch: true
line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m" line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m"
@ -1082,12 +1082,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertafter_test3_file register: insertafter_test3_file
- name: Insert the line using firstmatch and insertafter without regexp again - name: Insert the line using firstmatch and insertafter without regexp again
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
firstmatch: true firstmatch: true
line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m" line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m"
@ -1095,7 +1095,7 @@
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertafter_test4_file register: insertafter_test4_file
- name: Assert insertafter without regexp tests gave the expected results - name: Assert insertafter without regexp tests gave the expected results
@ -1111,7 +1111,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: test_58923.txt src: test_58923.txt
dest: "{{ output_dir }}/test_58923.txt" dest: "{{ remote_tmp_dir }}/test_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1123,7 +1123,7 @@
- name: Add the line using regexp, firstmatch, and insertbefore - name: Add the line using regexp, firstmatch, and insertbefore
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
regexp: ^export FISHEYE_OPTS regexp: ^export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1132,12 +1132,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertbefore_test1_file register: insertbefore_test1_file
- name: Add the line using regexp, firstmatch, and insertbefore again - name: Add the line using regexp, firstmatch, and insertbefore again
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
regexp: ^export FISHEYE_OPTS regexp: ^export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1146,7 +1146,7 @@
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertbefore_test2_file register: insertbefore_test2_file
- name: Assert insertbefore with regexp tests gave the expected results - name: Assert insertbefore with regexp tests gave the expected results
@ -1162,7 +1162,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: test_58923.txt src: test_58923.txt
dest: "{{ output_dir }}/test_58923.txt" dest: "{{ remote_tmp_dir }}/test_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1174,7 +1174,7 @@
- name: Add the line using insertbefore and firstmatch - name: Add the line using insertbefore and firstmatch
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
firstmatch: true firstmatch: true
line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m" line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m"
@ -1182,12 +1182,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertbefore_test3_file register: insertbefore_test3_file
- name: Add the line using insertbefore and firstmatch again - name: Add the line using insertbefore and firstmatch again
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
firstmatch: true firstmatch: true
line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m" line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m"
@ -1195,7 +1195,7 @@
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertbefore_test4_file register: insertbefore_test4_file
# Test when the line is presented in the file but # Test when the line is presented in the file but
@ -1204,7 +1204,7 @@
Add the line using insertbefore and firstmatch when the regexp line Add the line using insertbefore and firstmatch when the regexp line
is presented but not close to insertbefore spot is presented but not close to insertbefore spot
lineinfile: lineinfile:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
insertbefore: ' Darwin\*\) if \[ -z \"\$JAVA_HOME\" \] ; then' insertbefore: ' Darwin\*\) if \[ -z \"\$JAVA_HOME\" \] ; then'
firstmatch: true firstmatch: true
line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m" line: export FISHEYE_OPTS="-Xmx4096m -Xms2048m"
@ -1212,7 +1212,7 @@
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/test_58923.txt" path: "{{ remote_tmp_dir }}/test_58923.txt"
register: insertbefore_test5_file register: insertbefore_test5_file
- name: Assert insertbefore with regexp tests gave the expected results - name: Assert insertbefore with regexp tests gave the expected results
@ -1232,7 +1232,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: teststring_58923.txt src: teststring_58923.txt
dest: "{{ output_dir }}/teststring_58923.txt" dest: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1253,7 +1253,7 @@
# literal is not present in the file, so the line must be inserted after ^#!/bin/sh # literal is not present in the file, so the line must be inserted after ^#!/bin/sh
- name: Add the line using firstmatch, regexp, and insertafter - name: Add the line using firstmatch, regexp, and insertafter
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
search_string: export FISHEYE_OPTS search_string: export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1262,12 +1262,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: insertafter_test1_file register: insertafter_test1_file
- name: Add the line using firstmatch, literal, and insertafter again - name: Add the line using firstmatch, literal, and insertafter again
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
insertafter: '^#!/bin/sh' insertafter: '^#!/bin/sh'
search_string: export FISHEYE_OPTS search_string: export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1279,7 +1279,7 @@
# so nothing has been added: # so nothing has been added:
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: insertafter_test2_file register: insertafter_test2_file
- name: Assert insertafter tests gave the expected results - name: Assert insertafter tests gave the expected results
@ -1294,7 +1294,7 @@
- name: Deploy the test file - name: Deploy the test file
copy: copy:
src: teststring_58923.txt src: teststring_58923.txt
dest: "{{ output_dir }}/teststring_58923.txt" dest: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: initial_file register: initial_file
- name: Assert that the test file was deployed - name: Assert that the test file was deployed
@ -1306,7 +1306,7 @@
- name: Add the line using literal, firstmatch, and insertbefore - name: Add the line using literal, firstmatch, and insertbefore
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
search_string: export FISHEYE_OPTS search_string: export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1315,12 +1315,12 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: insertbefore_test1_file register: insertbefore_test1_file
- name: Add the line using literal, firstmatch, and insertbefore again - name: Add the line using literal, firstmatch, and insertbefore again
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
insertbefore: '^#!/bin/sh' insertbefore: '^#!/bin/sh'
search_string: export FISHEYE_OPTS search_string: export FISHEYE_OPTS
firstmatch: true firstmatch: true
@ -1329,7 +1329,7 @@
- name: Stat the file again - name: Stat the file again
stat: stat:
path: "{{ output_dir }}/teststring_58923.txt" path: "{{ remote_tmp_dir }}/teststring_58923.txt"
register: insertbefore_test2_file register: insertbefore_test2_file
- name: Assert insertbefore with literal tests gave the expected results - name: Assert insertbefore with literal tests gave the expected results
@ -1344,14 +1344,14 @@
# https://github.com/ansible/ansible/issues/63684 # https://github.com/ansible/ansible/issues/63684
- name: Create a file by inserting a line - name: Create a file by inserting a line
lineinfile: lineinfile:
path: "{{ output_dir }}/testend.txt" path: "{{ remote_tmp_dir }}/testend.txt"
create: yes create: yes
line: testline line: testline
register: testend1 register: testend1
- name: Insert a line at the end of the file - name: Insert a line at the end of the file
lineinfile: lineinfile:
path: "{{ output_dir }}/testend.txt" path: "{{ remote_tmp_dir }}/testend.txt"
insertafter: testline insertafter: testline
regexp: line at the end regexp: line at the end
line: line at the end line: line at the end
@ -1359,7 +1359,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/testend.txt" path: "{{ remote_tmp_dir }}/testend.txt"
register: testend_file register: testend_file
- name: Assert inserting at the end gave the expected results. - name: Assert inserting at the end gave the expected results.
@ -1373,14 +1373,14 @@
- name: Create a file by inserting a line - name: Create a file by inserting a line
lineinfile: lineinfile:
path: "{{ output_dir }}/testendliteral.txt" path: "{{ remote_tmp_dir }}/testendliteral.txt"
create: yes create: yes
line: testline line: testline
register: testend1 register: testend1
- name: Insert a line at the end of the file - name: Insert a line at the end of the file
lineinfile: lineinfile:
path: "{{ output_dir }}/testendliteral.txt" path: "{{ remote_tmp_dir }}/testendliteral.txt"
insertafter: testline insertafter: testline
search_string: line at the end search_string: line at the end
line: line at the end line: line at the end
@ -1388,7 +1388,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/testendliteral.txt" path: "{{ remote_tmp_dir }}/testendliteral.txt"
register: testend_file register: testend_file
- name: Assert inserting at the end gave the expected results. - name: Assert inserting at the end gave the expected results.

@ -5,7 +5,7 @@
- name: deploy the test file for lineinfile string - name: deploy the test file for lineinfile string
copy: copy:
src: teststring.txt src: teststring.txt
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: assert that the test file was deployed - name: assert that the test file was deployed
@ -17,7 +17,7 @@
- name: insert a line at the beginning of the file, and back it up - name: insert a line at the beginning of the file, and back it up
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: present state: present
line: "New line at the beginning" line: "New line at the beginning"
insertbefore: "BOF" insertbefore: "BOF"
@ -26,7 +26,7 @@
- name: insert a line at the beginning of the file again - name: insert a line at the beginning of the file again
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: present state: present
line: "New line at the beginning" line: "New line at the beginning"
insertbefore: "BOF" insertbefore: "BOF"
@ -34,7 +34,7 @@
- name: Replace a line using string - name: Replace a line using string
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: present state: present
line: "Thi$ i^ [ine 3" line: "Thi$ i^ [ine 3"
search_string: (\\w)(\\s+)([\\.,]) search_string: (\\w)(\\s+)([\\.,])
@ -42,13 +42,13 @@
- name: Replace a line again using string - name: Replace a line again using string
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: present state: present
line: "Thi$ i^ [ine 3" line: "Thi$ i^ [ine 3"
search_string: (\\w)(\\s+)([\\.,]) search_string: (\\w)(\\s+)([\\.,])
register: backrefs_result2 register: backrefs_result2
- command: cat {{ output_dir }}/teststring.txt - command: cat {{ remote_tmp_dir }}/teststring.txt
- name: assert that the line with backrefs was changed - name: assert that the line with backrefs was changed
assert: assert:
@ -59,7 +59,7 @@
- name: stat the test after the backref line was replaced - name: stat the test after the backref line was replaced
stat: stat:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: assert test checksum matches after backref line was replaced - name: assert test checksum matches after backref line was replaced
@ -69,7 +69,7 @@
- name: remove the middle line using string - name: remove the middle line using string
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: absent state: absent
search_string: "Thi$ i^ [ine 3" search_string: "Thi$ i^ [ine 3"
register: result register: result
@ -82,7 +82,7 @@
- name: stat the test after the middle line was removed - name: stat the test after the middle line was removed
stat: stat:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: assert test checksum matches after the middle line was removed - name: assert test checksum matches after the middle line was removed
@ -92,7 +92,7 @@
- name: run a validation script that succeeds using string - name: run a validation script that succeeds using string
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: absent state: absent
search_string: <FilesMatch ".py[45]?$"> search_string: <FilesMatch ".py[45]?$">
validate: "true %s" validate: "true %s"
@ -106,7 +106,7 @@
- name: stat the test after the validation succeeded - name: stat the test after the validation succeeded
stat: stat:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: assert test checksum matches after the validation succeeded - name: assert test checksum matches after the validation succeeded
@ -116,7 +116,7 @@
- name: run a validation script that fails using string - name: run a validation script that fails using string
lineinfile: lineinfile:
dest: "{{ output_dir }}/teststring.txt" dest: "{{ remote_tmp_dir }}/teststring.txt"
state: absent state: absent
search_string: "This is line 1" search_string: "This is line 1"
validate: "/bin/false %s" validate: "/bin/false %s"
@ -130,7 +130,7 @@
- name: stat the test after the validation failed - name: stat the test after the validation failed
stat: stat:
path: "{{ output_dir }}/teststring.txt" path: "{{ remote_tmp_dir }}/teststring.txt"
register: result register: result
- name: assert test checksum matches the previous after the validation failed - name: assert test checksum matches the previous after the validation failed

@ -5,7 +5,7 @@
- name: Deploy the teststring.conf file - name: Deploy the teststring.conf file
copy: copy:
src: teststring.conf src: teststring.conf
dest: "{{ output_dir }}/teststring.conf" dest: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the teststring.conf file was deployed - name: Assert that the teststring.conf file was deployed
@ -18,7 +18,7 @@
# Test instertafter # Test instertafter
- name: Insert lines after with string - name: Insert lines after with string
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
search_string: "{{ item.regexp }}" search_string: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
@ -27,7 +27,7 @@
- name: Do the same thing again and check for changes - name: Do the same thing again and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
search_string: "{{ item.regexp }}" search_string: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
@ -45,7 +45,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -55,7 +55,7 @@
- name: Do the same thing a third time without string and check for changes - name: Do the same thing a third time without string and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
line: "{{ item.line }}" line: "{{ item.line }}"
insertafter: "{{ item.after }}" insertafter: "{{ item.after }}"
with_items: "{{ test_befaf_regexp }}" with_items: "{{ test_befaf_regexp }}"
@ -63,7 +63,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file was changed when no string was provided - name: Assert that the file was changed when no string was provided
@ -74,7 +74,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -86,7 +86,7 @@
- name: Deploy the test.conf file - name: Deploy the test.conf file
copy: copy:
src: teststring.conf src: teststring.conf
dest: "{{ output_dir }}/teststring.conf" dest: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the teststring.conf file was deployed - name: Assert that the teststring.conf file was deployed
@ -98,7 +98,7 @@
- name: Insert lines before with string - name: Insert lines before with string
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
search_string: "{{ item.regexp }}" search_string: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
@ -107,7 +107,7 @@
- name: Do the same thing again and check for changes - name: Do the same thing again and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
search_string: "{{ item.regexp }}" search_string: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
@ -125,7 +125,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected
@ -135,7 +135,7 @@
- name: Do the same thing a third time without string and check for changes - name: Do the same thing a third time without string and check for changes
lineinfile: lineinfile:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
line: "{{ item.line }}" line: "{{ item.line }}"
insertbefore: "{{ item.before }}" insertbefore: "{{ item.before }}"
with_items: "{{ test_befaf_regexp }}" with_items: "{{ test_befaf_regexp }}"
@ -143,7 +143,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file was changed when no string was provided - name: Assert that the file was changed when no string was provided
@ -154,7 +154,7 @@
- name: Stat the file - name: Stat the file
stat: stat:
path: "{{ output_dir }}/teststring.conf" path: "{{ remote_tmp_dir }}/teststring.conf"
register: result register: result
- name: Assert that the file contents match what is expected - name: Assert that the file contents match what is expected

Loading…
Cancel
Save