diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index cede81b1f2..6ddbf8826a 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -50,7 +50,7 @@ nxos_argument_spec = { 'validate_certs': dict(type='bool'), 'timeout': dict(type='int'), - 'provider': dict(type='dict', no_log=True), + 'provider': dict(type='dict'), 'transport': dict(choices=['cli', 'nxapi']) } diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index ee97911783..fdb04463d5 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -203,7 +203,7 @@ class FactsBase(object): try: return resp[0] except IndexError: - self.warnings.append('command %s returned to data, facts will not be populated' % command_string) + self.warnings.append('command %s failed, facts will not be populated' % command_string) return None def transform_dict(self, data, keymap): @@ -290,13 +290,13 @@ class Interfaces(FactsBase): if data: self.facts['interfaces'] = self.populate_interfaces(data) - data = self.run('show ipv6 inteface', 'json') + data = self.run('show ipv6 interface', 'json') if data: - self.parse_ipv6_interfaces(out) + self.parse_ipv6_interfaces(data) data = self.run('show lldp neighbors') if data: - self.facts['neighbors'] = self.populate_neighbors(out) + self.facts['neighbors'] = self.populate_neighbors(data) def populate_interfaces(self, data): interfaces = dict() @@ -315,6 +315,11 @@ class Interfaces(FactsBase): return interfaces def populate_neighbors(self, data): + # if there are no neighbors the show command returns + # ERROR: No neighbour information + if data.startswith('ERROR'): + return dict() + data = data['TABLE_nbor']['ROW_nbor'] if isinstance(data, dict): data = [data] diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index 8c865c5c80..d2c9a7ff5b 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -57,6 +57,7 @@ class ActionModule(_ActionModule): pc = copy.deepcopy(self._play_context) pc.connection = 'network_cli' pc.network_os = 'nxos' + pc.remote_addr = provider['host'] or self._play_context.remote_addr pc.port = provider['port'] or self._play_context.port or 22 pc.remote_user = provider['username'] or self._play_context.connection_user pc.password = provider['password'] or self._play_context.password @@ -115,7 +116,10 @@ class ActionModule(_ActionModule): # make sure a transport value is set in args self._task.args['transport'] = transport - return super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(tmp, task_vars) + del result['invocation']['module_args']['provider'] + + return result def _get_socket_path(self, play_context): ssh = connection_loader.get('ssh', class_only=True)