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

catches exception in nxos_command and returns failed message (#22151)

Catches exception in Conditional check and returns appropriated failed
message
This commit is contained in:
Peter Sprygada 2017-03-01 11:41:31 -06:00 committed by Nathaniel Case
parent d9d2e6deb6
commit c26cac2a53

View file

@ -161,7 +161,7 @@ from ansible.module_utils.nxos import run_commands
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import string_types
from ansible.module_utils.netcli import Conditional
from ansible.module_utils.netcli import Conditional, FailedConditionalError
from ansible.module_utils.network_common import ComplexList
from ansible.module_utils.nxos import nxos_argument_spec, check_args
@ -241,11 +241,15 @@ def main():
responses = run_commands(module, commands)
for item in list(conditionals):
try:
if item(responses):
if match == 'any':
conditionals = list()
break
conditionals.remove(item)
except FailedConditionalError:
exc = get_exception()
module.fail_json(msg=str(exc))
if not conditionals:
break