From 736d6406c049851d9490a3d60d1da049629f3ceb Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Mon, 19 Feb 2018 10:11:43 +0530 Subject: fix nxos_config json pipeline error (#36236) Signed-off-by: Trishna Guha --- lib/ansible/modules/network/nxos/nxos_config.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_config.py b/lib/ansible/modules/network/nxos/nxos_config.py index 61ccc5036a..e59887747e 100644 --- a/lib/ansible/modules/network/nxos/nxos_config.py +++ b/lib/ansible/modules/network/nxos/nxos_config.py @@ -113,9 +113,9 @@ options: the modified lines are pushed to the device in configuration mode. If the replace argument is set to I(block) then the entire command block is pushed to the device in configuration mode if any - line is not correct. I(replace config) is supported on Nexus 9K device. + line is not correct. I(replace config) is supported only on Nexus 9K device. required: false - default: lineo + default: line choices: ['line', 'block', 'config'] force: description: @@ -290,6 +290,7 @@ backup_path: from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.connection import ConnectionError from ansible.module_utils.network.common.config import NetworkConfig, dumps from ansible.module_utils.network.nxos.nxos import get_config, load_config, run_commands from ansible.module_utils.network.nxos.nxos import get_capabilities @@ -390,12 +391,18 @@ def main(): config = None - info = get_capabilities(module).get('device_info', {}) - os_platform = info.get('network_os_platform', '') + try: + info = get_capabilities(module) + api = info.get('network_api', 'nxapi') + device_info = info.get('device_info', {}) + os_platform = device_info.get('network_os_platform', '') + except ConnectionError: + api = '' + os_platform = '' - if module.params['replace'] == 'config': + if api == 'cliconf' and module.params['replace'] == 'config': if '9K' not in os_platform: - module.fail_json(msg='replace: config is supported only for Nexus 9K series switches') + module.fail_json(msg='replace: config is supported only on Nexus 9K series switches') if module.params['replace_src']: if module.params['replace'] != 'config': -- cgit v1.2.1