From e8ff3c43ad2ddb8451d32883065026e7dedddae2 Mon Sep 17 00:00:00 2001 From: Peter Hudec Date: Mon, 3 Jun 2013 22:47:50 +0200 Subject: [PATCH] fixed first_available_file and roles support for copy and template action --- lib/ansible/runner/action_plugins/copy.py | 12 ++++++------ lib/ansible/runner/action_plugins/template.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index 4322fbfd33..21db6f6c0e 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -57,12 +57,12 @@ class ActionModule(object): 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_orig, self.runner.basedir, check=False) - if os.path.exists(fn): - source = 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'], 'files', fnt, self.runner.basedir, check=False) + if os.path.exists(fnd): + source = fnd found = True break if not found: diff --git a/lib/ansible/runner/action_plugins/template.py b/lib/ansible/runner/action_plugins/template.py index c5f6cbc094..a2eb51c1fa 100644 --- a/lib/ansible/runner/action_plugins/template.py +++ b/lib/ansible/runner/action_plugins/template.py @@ -60,7 +60,7 @@ class ActionModule(object): 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', fn_orig, self.runner.basedir, check=False) + fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fnt, self.runner.basedir, check=False) if os.path.exists(fnd): source = fnd found = True