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.
33 lines
730 B
YAML
33 lines
730 B
YAML
4 years ago
|
- name: Create a file with blockinfile
|
||
|
blockinfile:
|
||
|
path: "{{ output_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: "{{ output_dir_test }}/empty.txt"
|
||
|
block: |
|
||
|
Hey
|
||
|
there
|
||
|
state: absent
|
||
|
create: yes
|
||
|
register: empty_test_2
|
||
|
|
||
|
- stat:
|
||
|
path: "{{ output_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
|