From 4d71b31f7e00447aabfae1ba33130e01b2445e97 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Fri, 25 Jan 2013 23:14:52 +0100 Subject: [PATCH] Ensure destination and source are available before mangling them Fixes #1918. --- lib/ansible/runner/action_plugins/template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/runner/action_plugins/template.py b/lib/ansible/runner/action_plugins/template.py index c08ea0821a..7b5197c4e9 100644 --- a/lib/ansible/runner/action_plugins/template.py +++ b/lib/ansible/runner/action_plugins/template.py @@ -37,10 +37,6 @@ class ActionModule(object): source = options.get('src', None) dest = options.get('dest', None) - if dest.endswith("/"): - base = os.path.basename(source) - dest = os.path.join(dest, base) - if (source is None and 'first_available_file' not in inject) or dest is None: result = dict(failed=True, msg="src and dest are required") return ReturnData(conn=conn, comm_ok=False, result=result) @@ -62,6 +58,10 @@ class ActionModule(object): else: source = utils.template(self.runner.basedir, source, inject) + if dest.endswith("/"): + base = os.path.basename(source) + dest = os.path.join(dest, base) + # template the source data locally & transfer try: resultant = utils.template_from_file(self.runner.basedir, source, inject)