Commit 0a23601b authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

software/kvm: handle absence of module_name or module_args in ansible promise

parent a3af8c12
...@@ -51,7 +51,7 @@ md5sum = 4bcb07c1a9223e2d956651aa25d23654 ...@@ -51,7 +51,7 @@ md5sum = 4bcb07c1a9223e2d956651aa25d23654
[template-ansible-promise] [template-ansible-promise]
filename = template/ansible-promise.in filename = template/ansible-promise.in
md5sum = b7e87479a289f472b634a046b44b5257 md5sum = a8cf453d20f01c707f02c4b4014580d8
[template-kvm-run] [template-kvm-run]
filename = template/template-kvm-run.in filename = template/template-kvm-run.in
......
...@@ -17,11 +17,12 @@ result_failed_ignore = '127.0.0.1_FAILED_IGNORED' ...@@ -17,11 +17,12 @@ result_failed_ignore = '127.0.0.1_FAILED_IGNORED'
def get_log(res): def get_log(res):
log = "" log = ""
if type(res) == type(dict()): if type(res) == type(dict()):
log = '>> Running task: %s, args [%s]\n' % (res['invocation']['module_name'], module_name = res['invocation'].get('module_name', 'unkown_module_name')
res['invocation']['module_args']) module_args = res['invocation'].get('module_args', 'unkown_module_args')
log = '>> Running task: %s, args [%s]\n' % (module_name, module_args)
for field in FIELDS: for field in FIELDS:
if field in res.keys(): if field in res.keys():
# use default encoding, check out sys.setdefaultencoding # use default encoding, check out sys.setdefaultencoding
log += '\n{0}:\n{1}'.format(field, res[field]) log += '\n{0}:\n{1}'.format(field, res[field])
return log return log
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment