1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Tweak to only show msg on assert failure if set

This commit is contained in:
James Cammarata 2014-07-08 14:05:24 -05:00
parent 16332b8488
commit b8ac094eaa

View file

@ -38,8 +38,7 @@ class ActionModule(object):
args.update(complex_args)
args.update(utils.parse_kv(module_args))
msg = 'assertion failed'
msg = None
if 'msg' in args:
msg = args['msg']
@ -50,8 +49,16 @@ class ActionModule(object):
args['that'] = [ args['that'] ]
for that in args['that']:
result = utils.check_conditional(that, self.runner.basedir, inject, fail_on_undefined=True)
if not result:
return ReturnData(conn=conn, result=dict(failed=True, msg=msg, assertion=that, evaluated_to=result))
test_result = utils.check_conditional(that, self.runner.basedir, inject, fail_on_undefined=True)
if not test_result:
result = dict(
failed = True,
evaluated_to = test_result,
assertion = that,
)
if msg:
result['msg'] = msg
return ReturnData(conn=conn, result=result)
return ReturnData(conn=conn, result=dict(msg='all assertions passed'))