Add test for template module and make 'dark' errors clearer if we get output back and the JSON
is not parseable
This commit is contained in:
parent
c86b388812
commit
369b9cde1c
1 changed files with 5 additions and 5 deletions
|
@ -162,16 +162,16 @@ class Runner(object):
|
||||||
return [ True, ssh ]
|
return [ True, ssh ]
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# it failed somehow, return the failure string
|
# it failed somehow, return the failure string
|
||||||
return [ False, str(e) ]
|
return [ False, "FAILED: %s" % str(e) ]
|
||||||
|
|
||||||
def _return_from_module(self, conn, host, result):
|
def _return_from_module(self, conn, host, result):
|
||||||
''' helper function to handle JSON parsing of results '''
|
''' helper function to handle JSON parsing of results '''
|
||||||
try:
|
try:
|
||||||
# try to parse the JSON response
|
# try to parse the JSON response
|
||||||
return [ host, True, json.loads(result) ]
|
return [ host, True, json.loads(result) ]
|
||||||
except:
|
except Exception, e:
|
||||||
# it failed, say so, but return the string anyway
|
# it failed, say so, but return the string anyway
|
||||||
return [ host, False, result ]
|
return [ host, False, "%s/%s" % (str(e), result) ]
|
||||||
|
|
||||||
def _delete_remote_files(self, conn, files):
|
def _delete_remote_files(self, conn, files):
|
||||||
''' deletes one or more remote files '''
|
''' deletes one or more remote files '''
|
||||||
|
@ -279,11 +279,11 @@ class Runner(object):
|
||||||
self._transfer_file(conn, source, temppath)
|
self._transfer_file(conn, source, temppath)
|
||||||
|
|
||||||
# install the template module
|
# install the template module
|
||||||
module = self._transfer_module(conn, tmp, 'template')
|
template_module = self._transfer_module(conn, tmp, 'template')
|
||||||
|
|
||||||
# run the template module
|
# run the template module
|
||||||
args = [ "src=%s" % temppath, "dest=%s" % dest, "metadata=%s" % metadata ]
|
args = [ "src=%s" % temppath, "dest=%s" % dest, "metadata=%s" % metadata ]
|
||||||
result = self._execute_module(conn, tmp, module, args)
|
result = self._execute_module(conn, tmp, template_module, args)
|
||||||
self._delete_remote_files(conn, [ tpath ])
|
self._delete_remote_files(conn, [ tpath ])
|
||||||
return self._return_from_module(conn, host, result)
|
return self._return_from_module(conn, host, result)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue