1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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.
This commit is contained in:
Sam Doran 2017-08-15 12:41:16 -04:00 committed by GitHub
parent d69440c4ef
commit a8e4c9be7a
3 changed files with 434 additions and 212 deletions

View file

@ -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']

View file

@ -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