fetch: set fail_on_missing: True as default as per docs (#36469)

* fetch: set fail_on_missing: True as default as per docs

* Updated docs for fetch to say behaviour was changed in 2.5 and updated tests
This commit is contained in:
Jordan Borean 2018-02-21 18:10:23 +10:00 committed by GitHub
parent d5858bbcbe
commit df8a5d7a4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 6 deletions

View file

@ -41,9 +41,9 @@ options:
version_added: "1.1"
description:
- When set to 'yes', the task will fail if the remote file cannot be
read for any reason. Prior to Ansible-2.4, setting this would only fail
read for any reason. Prior to Ansible-2.5, setting this would only fail
if the source file was missing.
- The default was changed to "yes" in Ansible-2.4.
- The default was changed to "yes" in Ansible-2.5.
required: false
choices: [ "yes", "no" ]
default: "yes"
@ -73,8 +73,8 @@ notes:
depending on the file size can consume all available memory on the
remote or local hosts causing a C(MemoryError). Due to this it is
advisable to run this module without C(become) whenever possible.
- Prior to Ansible-2.4 this module would not fail if reading the remote
file was impossible unless fail_on_missing was set. In Ansible-2.4+,
- Prior to Ansible-2.5 this module would not fail if reading the remote
file was impossible unless fail_on_missing was set. In Ansible-2.5+,
playbook authors are encouraged to use fail_when or ignore_errors to
get this ability. They may also explicitly set fail_on_missing to False
to get the non-failing behaviour.

View file

@ -54,7 +54,7 @@ class ActionModule(ActionBase):
source = self._task.args.get('src', None)
dest = self._task.args.get('dest', None)
flat = boolean(self._task.args.get('flat'), strict=False)
fail_on_missing = boolean(self._task.args.get('fail_on_missing'), strict=False)
fail_on_missing = boolean(self._task.args.get('fail_on_missing', True), strict=False)
validate_checksum = boolean(self._task.args.get('validate_checksum',
self._task.args.get('validate_md5', True)),
strict=False)

View file

@ -77,6 +77,18 @@
- "fetch_missing.msg"
- "fetch_missing is not changed"
- name: attempt to fetch a non-existent file - fail on missing implicit
fetch: src={{ output_dir }}/doesnotexist dest={{ output_dir }}/fetched
register: fetch_missing_implicit
ignore_errors: true
- name: check fetch missing with failure with implicit fail
assert:
that:
- "fetch_missing_implicit is failed"
- "fetch_missing_implicit.msg"
- "fetch_missing_implicit is not changed"
- name: attempt to fetch a directory - should not fail but return a message
fetch: src={{ output_dir }} dest={{ output_dir }}/somedir fail_on_missing=False
register: fetch_dir

View file

@ -136,7 +136,7 @@
- "fetch_small_bs_stat.stat.checksum == fetch_small_bs.checksum"
- name: attempt to fetch a non-existent file - do not fail on missing
fetch: src="C:/this_file_should_not_exist.txt" dest={{ host_output_dir }}
fetch: src="C:/this_file_should_not_exist.txt" dest={{ host_output_dir }} fail_on_missing=no
register: fetch_missing_nofail
- name: check fetch missing no fail result
@ -158,6 +158,18 @@
- "fetch_missing.msg"
- "fetch_missing is not changed"
- name: attempt to fetch a non-existent file - fail on missing implicit
fetch: src="~/this_file_should_not_exist.txt" dest={{ host_output_dir }}
register: fetch_missing_implicit
ignore_errors: true
- name: check fetch missing with failure on implicit
assert:
that:
- "fetch_missing_implicit is failed"
- "fetch_missing_implicit.msg"
- "fetch_missing_implicit is not changed"
- name: attempt to fetch a directory
fetch: src="C:\\Windows" dest={{ host_output_dir }}
register: fetch_dir