diff --git a/lib/ansible/modules/network/nxos/nxos_config.py b/lib/ansible/modules/network/nxos/nxos_config.py index 8dae1f1f04..b6b23b2bfa 100644 --- a/lib/ansible/modules/network/nxos/nxos_config.py +++ b/lib/ansible/modules/network/nxos/nxos_config.py @@ -273,6 +273,7 @@ from ansible.module_utils.netcfg import NetworkConfig, dumps from ansible.module_utils.nxos import get_config, load_config, run_commands from ansible.module_utils.nxos import nxos_argument_spec from ansible.module_utils.nxos import check_args as nxos_check_args +from ansible.module_utils.network_common import to_list def get_running_config(module, config=None): @@ -296,6 +297,17 @@ def get_candidate(module): return candidate +def execute_show_commands(module, commands, output='text'): + cmds = [] + for command in to_list(commands): + cmd = { 'command': command, + 'output': output, + } + cmds.append(cmd) + body = run_commands(module, cmds) + return body + + def main(): """ main entry point for module execution """ @@ -396,7 +408,7 @@ def main(): module.params['save_when'] = 'always' if module.params['save_when'] != 'never': - output = run_commands(module, ['show running-config', 'show startup-config']) + output = execute_show_commands(module, ['show running-config', 'show startup-config']) running_config = NetworkConfig(indent=1, contents=output[0], ignore_lines=diff_ignore_lines) startup_config = NetworkConfig(indent=1, contents=output[1], ignore_lines=diff_ignore_lines) @@ -413,7 +425,7 @@ def main(): if module._diff: if not running_config: - output = run_commands(module, 'show running-config') + output = execute_show_commands(module, 'show running-config') contents = output[0] else: contents = running_config.config_text @@ -430,7 +442,7 @@ def main(): elif module.params['diff_against'] == 'startup': if not startup_config: - output = run_commands(module, 'show startup-config') + output = execute_show_commands(module, 'show startup-config') contents = output[0] else: contents = output[0] diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index 332c6b4b69..f8ce57b96e 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -171,7 +171,7 @@ import re from ansible.module_utils.nxos import run_commands, get_config from ansible.module_utils.nxos import nxos_argument_spec, check_args from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six import iteritems +from ansible.module_utils.six import string_types, iteritems class FactsBase(object): @@ -290,7 +290,7 @@ class Interfaces(FactsBase): self.facts['interfaces'] = self.populate_interfaces(data) data = self.run('show ipv6 interface', 'json') - if data: + if data and not isinstance(data, string_types): self.parse_ipv6_interfaces(data) data = self.run('show lldp neighbors')