catches exception if conditional cannot be parsed (#5067)

If the conditional cannot be parsed, the module will now catch the exception
and return a well formed failed message.

fixes #5060
This commit is contained in:
Peter Sprygada 2016-09-27 20:59:40 -04:00 committed by Matt Clay
parent da4c11241f
commit 73cf85d677

View file

@ -263,8 +263,12 @@ def main():
exc = get_exception()
warnings.append('duplicate command detected: %s' % cmd)
for item in conditionals:
runner.add_conditional(item)
try:
for item in conditionals:
runner.add_conditional(item)
except (ValueError, AttributeError):
exc = get_exception()
module.fail_json(msg=str(exc))
runner.retries = module.params['retries']
runner.interval = module.params['interval']