Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'fetch' test for local directories before creating. Fixes issue #450 #451

Merged
merged 3 commits into from
Jun 8, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def _execute_fetch(self, conn, tmp):
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,{})
Expand All @@ -477,11 +477,12 @@ def _execute_fetch(self, conn, tmp):
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
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)
Expand Down