From d600c650951812c69937b772bf26c9c89d17e24a Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 20 Apr 2015 11:15:31 -0500 Subject: [PATCH] Fix fetch action plugin in v2 to use the inventory_hostname in the dest dir Fixes #10736 --- v2/ansible/plugins/action/fetch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/v2/ansible/plugins/action/fetch.py b/v2/ansible/plugins/action/fetch.py index 58e7cebb8d2..c242c8739d0 100644 --- a/v2/ansible/plugins/action/fetch.py +++ b/v2/ansible/plugins/action/fetch.py @@ -94,7 +94,11 @@ class ActionModule(ActionBase): dest = self._loader.path_dwim(dest) else: # files are saved in dest dir, with a subdir for each host, then the filename - dest = "%s/%s/%s" % (self._loader.path_dwim(dest), self._connection_info.remote_addr, source_local) + if 'inventory_hostname' in task_vars: + target_name = task_vars['inventory_hostname'] + else: + target_name = self._connection_info.remote_addr + dest = "%s/%s/%s" % (self._loader.path_dwim(dest), target_name, source_local) dest = dest.replace("//","/")