From a6dccd63a132e2ab87a43b52e04c91ae965fd474 Mon Sep 17 00:00:00 2001 From: Fred Alger Date: Tue, 5 Jun 2012 10:38:12 -0400 Subject: [PATCH 1/3] Make 'fetch' test for local directories before creating. Fixes issue #450 --- lib/ansible/runner/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index c49abf17644..a65ddfe15b9 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -481,7 +481,8 @@ class Runner(object): if remote_md5 != local_md5: # create the containing directories, if needed - os.makedirs(os.path.dirname(dest)) + if not os.path.isdir(os.path.dirname(dest)): + os.makedirs(os.path.dirname(dest)) # fetch the file and check for changes conn.fetch_file(source, dest) From 859510ae0086898daeed3ce5a7e99e561f7045c0 Mon Sep 17 00:00:00 2001 From: Fred Alger Date: Tue, 5 Jun 2012 11:26:10 -0400 Subject: [PATCH 2/3] Fix remote md5 in fetch module, related to Issue #450 --- lib/ansible/runner/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index a65ddfe15b9..7b83619233a 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -477,7 +477,7 @@ class Runner(object): local_md5 = None if os.path.exists(dest): local_md5 = os.popen("md5sum %s" % dest).read().split()[0] - remote_md5 = self._low_level_exec_command(conn, "md5sum %s" % source, tmp, True)[0].split()[0] + remote_md5 = self._low_level_exec_command(conn, "md5sum %s" % source, tmp, True).split()[0] if remote_md5 != local_md5: # create the containing directories, if needed From 9a234ff9a2ad2f64378e649ab6617a7ca1ab3065 Mon Sep 17 00:00:00 2001 From: Fred Alger Date: Tue, 5 Jun 2012 11:30:34 -0400 Subject: [PATCH 3/3] Fix exception in fetch module when src or dest parameter omitted. --- lib/ansible/runner/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 7b83619233a..123c9e9cadb 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -460,7 +460,7 @@ class Runner(object): dest = options.get('dest', None) if source is None or dest is None: results = dict(failed=True, msg="src and dest are required") - return ReturnData(host=conn.host, error=True, results=results) + return ReturnData(host=conn.host, result=results) # apply templating to source argument inject = self.setup_cache.get(conn.host,{})