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:
parent
d5858bbcbe
commit
df8a5d7a4f
4 changed files with 30 additions and 6 deletions
|
@ -41,9 +41,9 @@ options:
|
||||||
version_added: "1.1"
|
version_added: "1.1"
|
||||||
description:
|
description:
|
||||||
- When set to 'yes', the task will fail if the remote file cannot be
|
- 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.
|
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
|
required: false
|
||||||
choices: [ "yes", "no" ]
|
choices: [ "yes", "no" ]
|
||||||
default: "yes"
|
default: "yes"
|
||||||
|
@ -73,8 +73,8 @@ notes:
|
||||||
depending on the file size can consume all available memory on the
|
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
|
remote or local hosts causing a C(MemoryError). Due to this it is
|
||||||
advisable to run this module without C(become) whenever possible.
|
advisable to run this module without C(become) whenever possible.
|
||||||
- Prior to Ansible-2.4 this module would not fail if reading the remote
|
- 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.4+,
|
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
|
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
|
get this ability. They may also explicitly set fail_on_missing to False
|
||||||
to get the non-failing behaviour.
|
to get the non-failing behaviour.
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ActionModule(ActionBase):
|
||||||
source = self._task.args.get('src', None)
|
source = self._task.args.get('src', None)
|
||||||
dest = self._task.args.get('dest', None)
|
dest = self._task.args.get('dest', None)
|
||||||
flat = boolean(self._task.args.get('flat'), strict=False)
|
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',
|
validate_checksum = boolean(self._task.args.get('validate_checksum',
|
||||||
self._task.args.get('validate_md5', True)),
|
self._task.args.get('validate_md5', True)),
|
||||||
strict=False)
|
strict=False)
|
||||||
|
|
|
@ -77,6 +77,18 @@
|
||||||
- "fetch_missing.msg"
|
- "fetch_missing.msg"
|
||||||
- "fetch_missing is not changed"
|
- "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
|
- 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
|
fetch: src={{ output_dir }} dest={{ output_dir }}/somedir fail_on_missing=False
|
||||||
register: fetch_dir
|
register: fetch_dir
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
- "fetch_small_bs_stat.stat.checksum == fetch_small_bs.checksum"
|
- "fetch_small_bs_stat.stat.checksum == fetch_small_bs.checksum"
|
||||||
|
|
||||||
- name: attempt to fetch a non-existent file - do not fail on missing
|
- 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
|
register: fetch_missing_nofail
|
||||||
|
|
||||||
- name: check fetch missing no fail result
|
- name: check fetch missing no fail result
|
||||||
|
@ -158,6 +158,18 @@
|
||||||
- "fetch_missing.msg"
|
- "fetch_missing.msg"
|
||||||
- "fetch_missing is not changed"
|
- "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
|
- name: attempt to fetch a directory
|
||||||
fetch: src="C:\\Windows" dest={{ host_output_dir }}
|
fetch: src="C:\\Windows" dest={{ host_output_dir }}
|
||||||
register: fetch_dir
|
register: fetch_dir
|
||||||
|
|
Loading…
Reference in a new issue