From 0ac4722b29ee92be7130c6d8b07e8251127df6a2 Mon Sep 17 00:00:00 2001 From: Tomasz Kontusz Date: Sun, 4 Feb 2018 12:58:35 +0100 Subject: [PATCH] Fix for #31477: return 'dest' from copy when file wasn't changed (cherry picked from commit 89ad40b1299bb99962533b6a046aa153e711ab5e) --- lib/ansible/plugins/action/copy.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/ansible/plugins/action/copy.py b/lib/ansible/plugins/action/copy.py index c78f3ada26..05e4cc64f5 100644 --- a/lib/ansible/plugins/action/copy.py +++ b/lib/ansible/plugins/action/copy.py @@ -566,17 +566,13 @@ class ActionModule(ActionBase): changed = changed or module_return.get('changed', False) - # the file module returns the file path as 'path', but - # the copy module uses 'dest', so add it if it's not there - if 'path' in module_return and 'dest' not in module_return: - module_return['dest'] = module_return['path'] - - # Delete tmp path if we were recursive or if we did not execute a module. - if not delete_remote_tmp or (delete_remote_tmp and not module_executed): - self._remove_tmp_path(tmp) - if module_executed and len(source_files['files']) == 1: result.update(module_return) + + # the file module returns the file path as 'path', but + # the copy module uses 'dest', so add it if it's not there + if 'path' in result and 'dest' not in result: + result['dest'] = result['path'] else: result.update(dict(dest=dest, src=source, changed=changed))