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.
ansible/test/integration/targets/blockinfile/tasks/create_file.yml

47 lines
982 B
YAML

- name: Create a file with blockinfile
blockinfile:
path: "{{ remote_tmp_dir_test }}/empty.txt"
block: |
Hey
there
state: present
create: yes
register: empty_test_1
- name: Run a task that results in an empty file
blockinfile:
path: "{{ remote_tmp_dir_test }}/empty.txt"
block: |
Hey
there
state: absent
create: yes
register: empty_test_2
- stat:
path: "{{ remote_tmp_dir_test }}/empty.txt"
register: empty_test_stat
- name: Ensure empty file was created
assert:
that:
- empty_test_1 is changed
- "'File created' in empty_test_1.msg"
- empty_test_2 is changed
- "'Block removed' in empty_test_2.msg"
- empty_test_stat.stat.size == 0
- block:
- name: Create file in current directory
blockinfile:
path: "empty.txt"
block: Hello.
state: present
create: yes
always:
- name: Remove file
file:
path: "empty.txt"
state: absent