Cause copy module to fail on empty string as source (#27975)
* Fail if an empty string is set as src for copy module Fixes #27363 * Cleanup task formatting on copy tests Use multi-line YAML Add debug statements with verbosity: 1 rather than leave them in there commented out. * Add test for empty string as source * Do more checks in order to add more specific errors messages Add more integration tests for the various failure scenarios. Cleanup some syntax on existing integration test tasks.pull/4420/head
parent
d69440c4ef
commit
a8e4c9be7a
|
@ -408,12 +408,14 @@ class ActionModule(ActionBase):
|
|||
local_follow = boolean(self._task.args.get('local_follow', True), strict=False)
|
||||
|
||||
result['failed'] = True
|
||||
if (source is None and content is None) or dest is None:
|
||||
result['msg'] = "src (or content) and dest are required"
|
||||
elif source is not None and content is not None:
|
||||
result['msg'] = "src and content are mutually exclusive"
|
||||
if not source and content is None:
|
||||
result['msg'] = 'src (or content) is required'
|
||||
elif not dest:
|
||||
result['msg'] = 'dest is required'
|
||||
elif source and content is not None:
|
||||
result['msg'] = 'src and content are mutually exclusive'
|
||||
elif content is not None and dest is not None and dest.endswith("/"):
|
||||
result['msg'] = "dest must be a file if content is defined"
|
||||
result['msg'] = "can not use content with a dir as dest"
|
||||
else:
|
||||
del result['failed']
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# output_dir is hardcoded in test/runner/lib/executor.py and created there
|
||||
remote_dir: '{{ output_dir }}'
|
||||
|
||||
- name: create remote unprivileged remote user
|
||||
- name: Create remote unprivileged remote user
|
||||
user:
|
||||
name: '{{ remote_unprivileged_user }}'
|
||||
register: user
|
||||
|
@ -21,7 +21,7 @@
|
|||
state: directory
|
||||
mode: 0700
|
||||
|
||||
- name: 'duplicate authorized_keys'
|
||||
- name: Duplicate authorized_keys
|
||||
copy:
|
||||
src: $HOME/.ssh/authorized_keys
|
||||
dest: '{{ user.home }}/.ssh/authorized_keys'
|
||||
|
@ -46,7 +46,7 @@
|
|||
state: absent
|
||||
connection: local
|
||||
|
||||
- name: remote unprivileged remote user
|
||||
- name: Remote unprivileged remote user
|
||||
user:
|
||||
name: '{{ remote_unprivileged_user }}'
|
||||
state: absent
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue