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

adds check for AddConditionError when adding conditional statements (#5123)

The Conditional instance will now raise the AddConditionError and this
change instructs eos_command to catch the error and return a nicely formed
error message
This commit is contained in:
Peter Sprygada 2016-10-02 14:57:58 -04:00 committed by Matt Clay
parent 48b0cb750c
commit f5e72c6590

View file

@ -149,7 +149,7 @@ import ansible.module_utils.eos
from ansible.module_utils.basic import get_exception
from ansible.module_utils.network import NetworkModule, NetworkError
from ansible.module_utils.netcli import CommandRunner
from ansible.module_utils.netcli import AddCommandError
from ansible.module_utils.netcli import AddCommandError, AddConditionError
from ansible.module_utils.netcli import FailedConditionsError
from ansible.module_utils.netcli import FailedConditionalError
from ansible.module_utils.six import string_types
@ -212,8 +212,13 @@ 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 AddConditionError:
exc = get_exception()
module.fail_json(msg=str(exc), condition=exc.condition)
runner.retries = module.params['retries']
runner.interval = module.params['interval']