Skip to content

Commit

Permalink
Fix logic surrounding copy and remote_src, remote_src is preferred, m…
Browse files Browse the repository at this point in the history
…ake copy action plugin only. Fixes #23591 (#24732)
  • Loading branch information
sivel authored and abadger committed May 23, 2017
1 parent f5fd32e commit 4ac135c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/ansible/modules/files/unarchive.py
Expand Up @@ -770,7 +770,6 @@ def main():
src = dict(required=True, type='path'),
original_basename = dict(required=False, type='str'), # used to handle 'dest is a directory' via template, a slight hack
dest = dict(required=True, type='path'),
copy = dict(required=False, default=True, type='bool'),
remote_src = dict(required=False, default=False, type='bool'),
creates = dict(required=False, type='path'),
list_files = dict(required=False, default=False, type='bool'),
Expand All @@ -780,21 +779,19 @@ def main():
validate_certs = dict(required=False, default=True, type='bool'),
),
add_file_common_args = True,
mutually_exclusive = [("copy", "remote_src"),],
# check-mode only works for zip files, we cover that later
supports_check_mode = True,
)

src = module.params['src']
dest = module.params['dest']
copy = module.params['copy']
remote_src = module.params['remote_src']
file_args = module.load_file_common_arguments(module.params)
# did tar file arrive?
if not os.path.exists(src):
if not remote_src and copy:
if not remote_src:
module.fail_json(msg="Source '%s' failed to transfer" % src)
# If copy=false, and src= contains ://, try and download the file to a temp directory.
# If remote_src=true, and src= contains ://, try and download the file to a temp directory.
elif '://' in src:
tempdir = os.path.dirname(os.path.realpath(__file__))
package = os.path.join(tempdir, str(src.rsplit('/', 1)[1]))
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/plugins/action/unarchive.py
Expand Up @@ -53,7 +53,7 @@ def run(self, tmp=None, task_vars=None):
return result
# We will take the information from copy and store it in
# the remote_src var to use later in this file.
remote_src = not boolean(self._task.args.get('copy'))
self._task.args['remote_src'] = remote_src = not boolean(self._task.args.pop('copy'))

if source is None or dest is None:
result['failed'] = True
Expand Down Expand Up @@ -128,7 +128,7 @@ def run(self, tmp=None, task_vars=None):
)

# remove action plugin only key
for key in ('remote_src', 'decrypt'):
for key in ('decrypt',):
if key in new_module_args:
del new_module_args[key]

Expand Down

0 comments on commit 4ac135c

Please sign in to comment.