From 2cc4ac2e7563e6b73666048c3624bf092f9959e1 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 14 Apr 2014 12:36:54 -0500 Subject: [PATCH] Catch traceback caused by permissions errors during a local md5 sum Fixes #6948 --- lib/ansible/utils/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 4abcd2cd82b..ff73e0629a5 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -590,12 +590,15 @@ def md5(filename): return None digest = _md5() blocksize = 64 * 1024 - infile = open(filename, 'rb') - block = infile.read(blocksize) - while block: - digest.update(block) + try: + infile = open(filename, 'rb') block = infile.read(blocksize) - infile.close() + while block: + digest.update(block) + block = infile.read(blocksize) + infile.close() + except IOError, e: + raise errors.AnsibleError("error while accessing the file %s, error was: %s" % (filename, e)) return digest.hexdigest() def default(value, function):