From da0209dbc43d3f6f5a659400d0015399025f5376 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 18 Apr 2012 21:12:48 -0400 Subject: [PATCH] The fetch module really should preserve the whole directory structure being fetched to allow subsequent calls, particularly in playbook, to recreate the host tree structure. Making it thus. --- lib/ansible/runner.py | 5 +++-- test/TestRunner.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py index dd7b66af275..7515f617839 100755 --- a/lib/ansible/runner.py +++ b/lib/ansible/runner.py @@ -404,8 +404,9 @@ class Runner(object): return (host, True, dict(failed=True, msg="src and dest are required"), '') # files are saved in dest dir, with a subdir for each host, then the filename - filename = os.path.basename(source) - dest = "%s/%s/%s" % (utils.path_dwim(self.basedir, dest), host, filename) + dest = "%s/%s/%s" % (utils.path_dwim(self.basedir, dest), host, source) + dest = dest.replace("//","/") + print "DEST=%s" % dest # compare old and new md5 for support of change hooks local_md5 = None diff --git a/test/TestRunner.py b/test/TestRunner.py index fc890125a56..529b4a6965a 100644 --- a/test/TestRunner.py +++ b/test/TestRunner.py @@ -201,9 +201,8 @@ class TestRunner(unittest.TestCase): def test_fetch(self): input = self._get_test_file('sample.j2') - output = self._get_stage_file('127.0.0.2/sample.j2') + output = os.path.join(self.stage_dir, '127.0.0.2', input) result = self._run('fetch', [ "src=%s" % input, "dest=%s" % self.stage_dir ]) - print "output file=%s" % output assert os.path.exists(output) assert open(input).read() == open(output).read()