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:
parent
d9d2e6deb6
commit
c26cac2a53
1 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue