Debian Codegraph @

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

raw
1 - name: Create a file with blockinfile
2 blockinfile:
3 path: "{{ remote_tmp_dir_test }}/empty.txt"
4 block: |
5 Hey
6 there
7 state: present
8 create: yes
9 register: empty_test_1
10
11 - name: Run a task that results in an empty file
12 blockinfile:
13 path: "{{ remote_tmp_dir_test }}/empty.txt"
14 block: |
15 Hey
16 there
17 state: absent
18 create: yes
19 register: empty_test_2
20
21 - stat:
22 path: "{{ remote_tmp_dir_test }}/empty.txt"
23 register: empty_test_stat
24
25 - name: Ensure empty file was created
26 assert:
27 that:
28 - empty_test_1 is changed
29 - "'File created' in empty_test_1.msg"
30 - empty_test_2 is changed
31 - "'Block removed' in empty_test_2.msg"
32 - empty_test_stat.stat.size == 0
33
34 - block:
35 - name: Create file in current directory
36 blockinfile:
37 path: "empty.txt"
38 block: Hello.
39 state: present
40 create: yes
41
42 always:
43 - name: Remove file
44 file:
45 path: "empty.txt"
46 state: absent