From 6e2ea327d145a90000e140b7c8606415e0374f37 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 11 Mar 2013 17:11:53 -0400 Subject: [PATCH] A very simple fix to enable spaces in the files sent via the copy module. --- lib/ansible/module_common.py | 4 ++-- lib/ansible/runner/action_plugins/copy.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index 825a3bcf65..df0500ca3d 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -629,8 +629,8 @@ class AnsibleModule(object): for x in items: try: (k, v) = x.split("=",1) - except: - self.fail_json(msg="this module requires key=value arguments") + except Exception, e: + self.fail_json(msg="this module requires key=value arguments (%s)" % items) params[k] = v params2 = json.loads(MODULE_COMPLEX_ARGS) params2.update(params) diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index afbbc1f493..f017b5e1f5 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -23,6 +23,7 @@ from ansible.runner.return_data import ReturnData import base64 import stat import tempfile +import pipes class ActionModule(object): @@ -119,7 +120,7 @@ class ActionModule(object): self.runner._low_level_exec_command(conn, "chmod a+r %s" % tmp_src, tmp) # run the copy module - module_args = "%s src=%s" % (module_args, tmp_src) + module_args = "%s src=%s" % (module_args, pipes.quote(tmp_src)) return self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject, complex_args=complex_args) else: @@ -129,7 +130,7 @@ class ActionModule(object): if content is not None: os.remove(tmp_content) tmp_src = tmp + os.path.basename(source) - module_args = "%s src=%s" % (module_args, tmp_src) + module_args = "%s src=%s" % (module_args, pipes.quote(tmp_src)) if self.runner.check: module_args = "%s CHECKMODE=True" % module_args return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject, complex_args=complex_args)