From 58a5ec6c51acefce346b8c1e724a701db78d82f4 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Wed, 28 Sep 2016 20:58:33 -0400 Subject: [PATCH] fixes junos_command module paring of wait_for strings (#5083) The junos_command module wasn't properly parsing strings to apply conditionals due to the return value not being converted to json before the results where handed to the runner. --- lib/ansible/modules/network/junos/junos_command.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py index f370ace3d8a..02b2a04e7b0 100644 --- a/lib/ansible/modules/network/junos/junos_command.py +++ b/lib/ansible/modules/network/junos/junos_command.py @@ -151,12 +151,6 @@ failed_conditionals: retured: failed type: list sample: ['...', '...'] - -xml: - description: The raw XML reply from the device - returned: when format is xml - type: list - sample: [['...', '...'], ['...', '...']] """ import ansible.module_utils.junos @@ -164,6 +158,7 @@ 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, FailedConditionsError +from ansible.module_utils.netcli import FailedConditionalError from ansible.module_utils.junos import xml_to_json from ansible.module_utils.six import string_types @@ -279,24 +274,23 @@ def main(): except FailedConditionsError: exc = get_exception() module.fail_json(msg=str(exc), failed_conditions=exc.failed_conditions) + except FailedConditionalError: + exc = get_exception() + module.fail_json(msg=str(exc), failed_conditional=exc.failed_conditional) except NetworkError: exc = get_exception() module.fail_json(msg=str(exc)) result = dict(changed=False, stdout=list()) - xmlout = list() for cmd in commands: try: output = runner.get_command(cmd['command'], cmd.get('output')) - xmlout.append(output) - output = xml_to_json(output) except ValueError: output = 'command not executed due to check_mode, see warnings' result['stdout'].append(output) result['warnings'] = warnings - result['xml'] = xmlout result['stdout_lines'] = list(to_lines(result['stdout'])) module.exit_json(**result)