Update file.py's initial_diff() to list existing when state: absent (#56353)

This commit is contained in:
Iain Madder
2019-06-07 14:55:51 +01:00
committed by Sam Doran
parent fba67bbe53
commit 91d326cb68
3 changed files with 38 additions and 2 deletions

View File

@@ -243,7 +243,7 @@
when: selinux_installed.stdout != ""
ignore_errors: true
- name: remote directory foobar
- name: remove directory foobar
file: path={{output_dir}}/foobar state=absent
- name: remove file foo.txt
@@ -258,6 +258,24 @@
- name: copy directory structure over
copy: src=foobar dest={{output_dir}}
- name: check what would be removed if folder state was absent and diff is enabled
file:
path: "{{ output_dir }}"
state: absent
check_mode: yes
diff: yes
register: folder_absent_result
- name: assert that the absent check lists expected files and folders
assert:
that:
- folder_absent_result.diff.before.path_content is defined
- test_folder in folder_absent_result.diff.before.path_content.directories
- test_file in folder_absent_result.diff.before.path_content.files
vars:
test_folder: "{{ folder_absent_result.path }}/foobar"
test_file: "{{ folder_absent_result.path }}/foobar/fileA"
- name: Change ownership of a directory with recurse=no(default)
file: path={{output_dir}}/foobar owner=1234