summaryrefslogtreecommitdiff
path: root/test/integration/targets
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2020-05-21 16:35:45 -0400
committerGitHub <noreply@github.com>2020-05-21 16:35:45 -0400
commitcd8920af998e297a549a4f05cf4a4b3656d7d67e (patch)
treeb2cb33c74902768afc70b5881372e2113b4dd1b8 /test/integration/targets
parente0f25a2b1f9e6c21f751ba0ed2dc2eee2152983e (diff)
downloadansible-cd8920af998e297a549a4f05cf4a4b3656d7d67e.tar.gz
file - return 'state': 'absent' when a file does not exist (#66503)
This was changed in ansible/ansible#51350.
Diffstat (limited to 'test/integration/targets')
-rw-r--r--test/integration/targets/file/tasks/main.yml21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml
index 8731c55474..4e1d88e6ba 100644
--- a/test/integration/targets/file/tasks/main.yml
+++ b/test/integration/targets/file/tasks/main.yml
@@ -61,6 +61,25 @@
- "file_result.changed == false"
- "file_result.state == 'file'"
+- name: Make sure file does not exist
+ file:
+ path: /tmp/ghost
+ state: absent
+
+- name: Target a file that does not exist
+ file:
+ path: /tmp/ghost
+ ignore_errors: yes
+ register: ghost_file_result
+
+- name: Validate ghost file results
+ assert:
+ that:
+ - ghost_file_result is failed
+ - ghost_file_result is not changed
+ - ghost_file_result.state == 'absent'
+ - "'cannot continue' in ghost_file_result.msg"
+
- name: verify that we are checking an absent file
file: path={{output_dir}}/bar.txt state=absent
register: file2_result
@@ -269,7 +288,7 @@
copy: src=foobar dest={{output_dir}}
- name: check what would be removed if folder state was absent and diff is enabled
- file:
+ file:
path: "{{ item }}"
state: absent
check_mode: yes