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