summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2018-02-19 10:11:43 +0530
committerGitHub <noreply@github.com>2018-02-19 10:11:43 +0530
commit736d6406c049851d9490a3d60d1da049629f3ceb (patch)
tree1d8dd06aa2ef04a2dbe4cbe0cbfa89743e7eef1c
parenta5654bd63c725c05f72235650bcd8dfecc861508 (diff)
downloadansible-736d6406c049851d9490a3d60d1da049629f3ceb.tar.gz
fix nxos_config json pipeline error (#36236)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
-rw-r--r--lib/ansible/modules/network/nxos/nxos_config.py19
1 files 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':