Debian Codegraph @

test/integration/targets/blockinfile/tasks/file_without_trailing_newline.yml

raw
1 - name: Create file without trailing newline
2 copy:
3 content: '# File with no newline'
4 dest: "{{ remote_tmp_dir_test }}/no_newline_at_end.txt"
5 register: no_newline
6
7
8 - name: Add block to file that does not have a newline at the end
9 blockinfile:
10 path: "{{ remote_tmp_dir_test }}/no_newline_at_end.txt"
11 content: |
12 one
13 two
14 three
15 register: no_newline_test1
16
17 - name: Add block to file that does not have a newline at the end again
18 blockinfile:
19 path: "{{ remote_tmp_dir_test }}/no_newline_at_end.txt"
20 content: |
21 one
22 two
23 three
24 register: no_newline_test2
25
26 - name: Stat the file
27 stat:
28 path: "{{ remote_tmp_dir_test }}/no_newline_at_end.txt"
29 register: no_newline_file
30
31 - name: Ensure block was correctly written to file with no newline at end
32 assert:
33 that:
34 - no_newline_test1 is changed
35 - no_newline_test2 is not changed
36 - no_newline_file.stat.checksum == 'dab16f864025e59125e74d1498ffb2bb048224e6'