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