|
|
@ -544,3 +544,167 @@
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- result.stat.checksum == 'a8452bb3643be8d18ba3fc212632b1633bd9f885'
|
|
|
|
- result.stat.checksum == 'a8452bb3643be8d18ba3fc212632b1633bd9f885'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################################
|
|
|
|
|
|
|
|
# Issue 36156
|
|
|
|
|
|
|
|
# Test insertbefore and insertafter with regexp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy the test.conf file
|
|
|
|
|
|
|
|
copy:
|
|
|
|
|
|
|
|
src: test.conf
|
|
|
|
|
|
|
|
dest: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the test.conf file was deployed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- result.checksum == '6037f13e419b132eb3fd20a89e60c6c87a6add38'
|
|
|
|
|
|
|
|
- result.state == 'file'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test instertafter
|
|
|
|
|
|
|
|
- name: Insert lines after with regexp
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
regexp: "{{ item.regexp }}"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertafter: "{{ item.after }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Do the same thing again and check for changes
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
regexp: "{{ item.regexp }}"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertafter: "{{ item.after }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file was changed the first time but not the second time
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- item.0 is changed
|
|
|
|
|
|
|
|
- item.1 is not changed
|
|
|
|
|
|
|
|
with_together:
|
|
|
|
|
|
|
|
- "{{ _multitest_5.results }}"
|
|
|
|
|
|
|
|
- "{{ _multitest_6.results }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file contents match what is expected
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result.stat.checksum == '06e2c456e5028dd7bcd0b117b5927a1139458c82'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Do the same thing a third time without regexp and check for changes
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertafter: "{{ item.after }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file was changed when no regexp was provided
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- item is changed
|
|
|
|
|
|
|
|
with_items: "{{ _multitest_7.results }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file contents match what is expected
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result.stat.checksum == '5bf50f3d74afd20de4010ca5c04bc7037b062d30'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test insertbefore
|
|
|
|
|
|
|
|
- name: Deploy the test.conf file
|
|
|
|
|
|
|
|
copy:
|
|
|
|
|
|
|
|
src: test.conf
|
|
|
|
|
|
|
|
dest: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the test.conf file was deployed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- result.checksum == '6037f13e419b132eb3fd20a89e60c6c87a6add38'
|
|
|
|
|
|
|
|
- result.state == 'file'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Insert lines before with regexp
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
regexp: "{{ item.regexp }}"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertbefore: "{{ item.before }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Do the same thing again and check for changes
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
regexp: "{{ item.regexp }}"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertbefore: "{{ item.before }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file was changed the first time but not the second time
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- item.0 is changed
|
|
|
|
|
|
|
|
- item.1 is not changed
|
|
|
|
|
|
|
|
with_together:
|
|
|
|
|
|
|
|
- "{{ _multitest_8.results }}"
|
|
|
|
|
|
|
|
- "{{ _multitest_9.results }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file contents match what is expected
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result.stat.checksum == 'c3be9438a07c44d4c256cebfcdbca15a15b1db91'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Do the same thing a third time without regexp and check for changes
|
|
|
|
|
|
|
|
lineinfile:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
|
|
|
|
insertbefore: "{{ item.before }}"
|
|
|
|
|
|
|
|
with_items: "{{ test_befaf_regexp }}"
|
|
|
|
|
|
|
|
register: _multitest_10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file was changed when no regexp was provided
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- item is changed
|
|
|
|
|
|
|
|
with_items: "{{ _multitest_10.results }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Stat the file
|
|
|
|
|
|
|
|
stat:
|
|
|
|
|
|
|
|
path: "{{ output_dir }}/test.conf"
|
|
|
|
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that the file contents match what is expected
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- result.stat.checksum == 'eca8d8ea089d4ea57a3b87d4091599ca8b60dfd2'
|
|
|
|