|
|
|
@ -114,7 +114,7 @@
|
|
|
|
|
- "result.stat.md5 == 'd5955ee042139dfef16dbe3a7334475f'"
|
|
|
|
|
|
|
|
|
|
- name: replace a line with backrefs
|
|
|
|
|
lineinfile: dest={{output_dir}}/test.txt state=present line="This is line 3" backrefs=yes regexp="^(REF) .* \1$"
|
|
|
|
|
lineinfile: dest={{output_dir}}/test.txt state=present line="This is line 3" backrefs=yes regexp="^(REF) .* \\1$"
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
- name: assert that the line with backrefs was changed
|
|
|
|
@ -209,3 +209,40 @@
|
|
|
|
|
that:
|
|
|
|
|
- "result.stat.md5 == 'fef1d487711facfd7aa2c87d788c19d9'"
|
|
|
|
|
|
|
|
|
|
- name: insert a multiple lines at the end of the file
|
|
|
|
|
lineinfile: dest={{output_dir}}/test.txt state=present line="This is a line\nwith \\\n character" insertafter="EOF"
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
- name: assert that the multiple lines was inserted
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "result.changed == true"
|
|
|
|
|
- "result.msg == 'line added'"
|
|
|
|
|
|
|
|
|
|
- stat: path={{output_dir}}/test.txt
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
- name: assert test md5 matches after insert the multiple lines
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "result.stat.md5 == 'c2510d5bc8fdef8e752b8f8e74c784c2'"
|
|
|
|
|
|
|
|
|
|
- name: replace a line with backrefs included in the line
|
|
|
|
|
lineinfile: dest={{output_dir}}/test.txt state=present line="New \\1 created with the backref" backrefs=yes regexp="^This is (line 4)$"
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
- name: assert that the line with backrefs was changed
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "result.changed == true"
|
|
|
|
|
- "result.msg == 'line replaced'"
|
|
|
|
|
|
|
|
|
|
- name: stat the test after the backref line was replaced
|
|
|
|
|
stat: path={{output_dir}}/test.txt
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
- name: assert test md5 matches after backref line was replaced
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "result.stat.md5 == '65f955c2a9722fd43d07103d7756ff9b'"
|
|
|
|
|
|
|
|
|
|