From 4503413baa3b8b6891b1125ac5b3774b961a3847 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2013 10:51:04 +1000 Subject: [PATCH 1/5] ReturnData is used throughout but not actually imported --- lib/ansible/runner/action_plugins/assemble.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index 468dee89ff..dbcad0cc9a 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -22,6 +22,7 @@ import pipes import shutil import tempfile from ansible import utils +from ansible.runner.return_data import ReturnData class ActionModule(object): From da44a7f0cbc593561af2dd7950f090748ac6436d Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2013 10:53:00 +1000 Subject: [PATCH 2/5] I think that resultant is meant to be the contents of the combined file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is used for the transfer and as a diff param but isn’t actually defined anywhere before it’s used. This seemed like the least bad place to set it. --- lib/ansible/runner/action_plugins/assemble.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index dbcad0cc9a..d20b68b1d5 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -71,6 +71,7 @@ class ActionModule(object): remote_md5 = self.runner._remote_md5(conn, tmp, dest) if pathmd5 != remote_md5: + resultant = file(path).read() if self.runner.diff: dest_result = self.runner._execute_module(conn, tmp, 'slurp', "path=%s" % dest, inject=inject, persist_files=True) if 'content' in dest_result.result: From 7b01c831595082f1809efed2725c6e030838bef8 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2013 10:55:35 +1000 Subject: [PATCH 3/5] =?UTF-8?q?Passing=20in=20complex=5Fargs=20throws=20?= =?UTF-8?q?=E2=80=98unsupported=20parameter=20for=20module=E2=80=99=20erro?= =?UTF-8?q?rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using assemble only params (e.g. remote_src) the copy (and I’m guessing file) modules throw an error that the param isn’t supported. Simply removing the complex_args param fixes it for me, but I’m not sure that’s the correct thing to do --- lib/ansible/runner/action_plugins/assemble.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index d20b68b1d5..b72572ef72 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -92,8 +92,8 @@ class ActionModule(object): if self.runner.noop_on_check(inject): return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), diff=dict(before_header=dest, after_header=src, before=dest_contents, after=resultant)) else: - res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject, complex_args=complex_args) res.diff = dict(before=dest_contents, after=resultant) + res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject) return res else: - return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject, complex_args=complex_args) + return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject) From e2d03173d2bbd3106916b38a092c894c160b7d92 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2013 10:58:14 +1000 Subject: [PATCH 4/5] =?UTF-8?q?The=20file=20module=20doesn=E2=80=99t=20hav?= =?UTF-8?q?e=20it=E2=80=99s=20module=5Fargs=20reset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I believe that this should be reset in the same way that the copy module does --- lib/ansible/runner/action_plugins/assemble.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index b72572ef72..aeabc0d4ca 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -96,4 +96,5 @@ class ActionModule(object): res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject) return res else: + module_args = "%s src=%s dest=%s original_basename=%s" % (module_args, pipes.quote(xfered), pipes.quote(dest), pipes.quote(os.path.basename(src))) return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject) From eed32ea70ce7fcd850f10ef174c48daad91407a7 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2013 10:59:51 +1000 Subject: [PATCH 5/5] =?UTF-8?q?dest=5Fcontents=20isn=E2=80=99t=20always=20?= =?UTF-8?q?defined,=20so=20don=E2=80=99t=20pass=20it=20around?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I think this is also a bit of a hack since it should probably be set before being used, I’m just not sure what it should be set to. --- lib/ansible/runner/action_plugins/assemble.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index aeabc0d4ca..ad6caf3c6f 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -90,10 +90,10 @@ class ActionModule(object): module_args = "%s src=%s dest=%s original_basename=%s" % (module_args, pipes.quote(xfered), pipes.quote(dest), pipes.quote(os.path.basename(src))) if self.runner.noop_on_check(inject): - return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), diff=dict(before_header=dest, after_header=src, before=dest_contents, after=resultant)) + return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), diff=dict(before_header=dest, after_header=src, after=resultant)) else: - res.diff = dict(before=dest_contents, after=resultant) res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject) + res.diff = dict(after=resultant) return res else: module_args = "%s src=%s dest=%s original_basename=%s" % (module_args, pipes.quote(xfered), pipes.quote(dest), pipes.quote(os.path.basename(src)))