mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
788 B
YAML
38 lines
788 B
YAML
4 years ago
|
- name: Create insertafter test file
|
||
|
copy:
|
||
|
dest: "{{ output_dir }}/after.txt"
|
||
|
content: |
|
||
|
line1
|
||
|
line2
|
||
|
line3
|
||
|
|
||
|
- name: Add block using insertafter
|
||
|
blockinfile:
|
||
|
path: "{{ output_dir }}/after.txt"
|
||
|
insertafter: line2
|
||
|
block: |
|
||
|
block1
|
||
|
block2
|
||
|
register: after1
|
||
|
|
||
|
- name: Add block using insertafter again
|
||
|
blockinfile:
|
||
|
path: "{{ output_dir }}/after.txt"
|
||
|
insertafter: line2
|
||
|
block: |
|
||
|
block1
|
||
|
block2
|
||
|
register: after2
|
||
|
|
||
|
- name: Stat the after.txt file
|
||
|
stat:
|
||
|
path: "{{ output_dir }}/after.txt"
|
||
|
register: after_file
|
||
|
|
||
|
- name: Ensure insertafter worked correctly
|
||
|
assert:
|
||
|
that:
|
||
|
- after1 is changed
|
||
|
- after2 is not changed
|
||
|
- after_file.stat.checksum == 'a8adeb971358230a28ce554f3b8fdd1ef65fdf1c'
|