From c63207bf754a8499bbfb4237fdb8b1ade69adfa5 Mon Sep 17 00:00:00 2001 From: Darryl Stoflet Date: Thu, 11 Apr 2013 20:40:23 -0700 Subject: [PATCH] Quick fix for first_available_file and roles --- lib/ansible/runner/action_plugins/copy.py | 3 ++- lib/ansible/runner/action_plugins/template.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index b1e5bac835..c633366e46 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -55,10 +55,11 @@ class ActionModule(object): if 'first_available_file' in inject: found = False for fn in inject.get('first_available_file'): + fn_orig = fn fn = template.template(self.runner.basedir, fn, inject) fn = utils.path_dwim(self.runner.basedir, fn) if not os.path.exists(fn) and '_original_file' in inject: - fn = utils.path_dwim_relative(inject['_original_file'], 'files', fn, self.runner.basedir, check=False) + fn = utils.path_dwim_relative(inject['_original_file'], 'files', fn_orig, self.runner.basedir, check=False) if os.path.exists(fn): source = fn found = True diff --git a/lib/ansible/runner/action_plugins/template.py b/lib/ansible/runner/action_plugins/template.py index 4f419c99ff..c5f6cbc094 100644 --- a/lib/ansible/runner/action_plugins/template.py +++ b/lib/ansible/runner/action_plugins/template.py @@ -54,15 +54,15 @@ class ActionModule(object): # look up the files and use the first one we find as src if 'first_available_file' in inject: - found = False for fn in self.runner.module_vars.get('first_available_file'): + fn_orig = fn fnt = template.template(self.runner.basedir, fn, inject) fnd = utils.path_dwim(self.runner.basedir, fnt) if not os.path.exists(fnd) and '_original_file' in inject: - fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fnd, self.runner.basedir, check=False) + fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fn_orig, self.runner.basedir, check=False) if os.path.exists(fnd): - source = fnt + source = fnd found = True break if not found: