From 02b8e17f61e8e5b6b4f621d6067e13d2d737daf0 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 15 Apr 2015 05:05:41 -0700 Subject: [PATCH] Tar --diff only sends output to stderr if a file is missing. Handle that case Fixes #1064 --- lib/ansible/modules/files/unarchive.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/files/unarchive.py b/lib/ansible/modules/files/unarchive.py index 7804d1bc02..af9310679b 100644 --- a/lib/ansible/modules/files/unarchive.py +++ b/lib/ansible/modules/files/unarchive.py @@ -75,9 +75,14 @@ EXAMPLES = ''' - unarchive: src=/tmp/foo.zip dest=/usr/local/bin copy=no ''' +import re import os from zipfile import ZipFile +# String from tar that shows the tar contents are different from the +# filesystem +DIFFERENCE_RE = re.compile(r': (.*) differs$') + class UnarchiveError(Exception): pass @@ -168,9 +173,12 @@ class TgzArchive(object): # What is different changes = set() - difference_re = re.compile(r': (.*) differs$') + if err: + # Assume changes if anything returned on stderr + # * Missing files are known to trigger this + return dict(unarchived=unarchived, rc=rc, out=out, err=err, cmd=cmd) for line in out.splitlines(): - match = difference_re.search(line) + match = DIFFERENCE_RE.search(line) if not match: # Unknown tar output. Assume we have changes return dict(unarchived=unarchived, rc=rc, out=out, err=err, cmd=cmd)