diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index 36b8a3306e2..a201e0b99a1 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -169,7 +169,7 @@ class Cli: except ValueError: out = to_text(out).strip() - if item['output'] == 'json' and out != 'ok' and isinstance(out, string_types): + if item['output'] == 'json' and out != '' and isinstance(out, string_types): self._module.fail_json(msg='failed to retrieve output of %s in json format' % item['command']) responses.append(out) diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index 4938e3adf07..0d8de5ec194 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -488,6 +488,9 @@ def get_interface_config_commands(interface, intf, existing): if mtu != 'None': commands.append('mtu {0}'.format(mtu)) + if 'mtu None' in commands: + commands.pop() + admin_state = interface.get('admin_state') if admin_state: command = get_admin_state(interface, intf, admin_state) diff --git a/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml index 683a551e8df..a3a2c29b8b5 100644 --- a/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -21,8 +21,8 @@ local_file: "./nxos.yaml" file_system: "bootflash:" provider: "{{ cli }}" - username: "{{ nxos_cli_user | default('admin') }}" - password: "{{ nxos_cli_pass | default('admin') }}" + username: "{{ ansible_ssh_user }}" + password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" register: result @@ -48,8 +48,8 @@ remote_file: "nxos.yaml" file_system: "bootflash:" provider: "{{ cli }}" - username: "{{ nxos_cli_user | default('admin') }}" - password: "{{ nxos_cli_pass | default('admin') }}" + username: "{{ ansible_ssh_user }}" + password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" register: result diff --git a/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml index 214b1fb3f55..b73c3e2c22b 100644 --- a/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml +++ b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml @@ -23,8 +23,8 @@ local_file: "./nxos.yaml" file_system: "bootflash:" provider: "{{ nxapi }}" - username: "{{ nxos_nxapi_user | default('admin') }}" - password: "{{ nxos_nxapi_pass | default('admin') }}" + username: "{{ ansible_ssh_user }}" + password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" register: result @@ -51,8 +51,8 @@ remote_file: "nxos.yaml" file_system: "bootflash:" provider: "{{ nxapi }}" - username: "{{ nxos_nxapi_user | default('admin') }}" - password: "{{ nxos_nxapi_pass | default('admin') }}" + username: "{{ ansible_ssh_user }}" + password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" register: result diff --git a/test/units/modules/network/nxos/test_nxos_interface.py b/test/units/modules/network/nxos/test_nxos_interface.py index a6afed2e464..b9e14f1abb6 100644 --- a/test/units/modules/network/nxos/test_nxos_interface.py +++ b/test/units/modules/network/nxos/test_nxos_interface.py @@ -62,14 +62,12 @@ class TestNxosInterfaceModule(TestNxosModule): def test_nxos_interface_up(self): set_module_args(dict(interface='loopback0')) result = self.execute_module(changed=True) - self.assertIn('interface loopback0', result['commands']) - self.assertIn('no shutdown', result['commands']) + self.assertEqual(result['commands'], ['interface loopback0', 'no shutdown']) def test_nxos_interface_down(self): set_module_args(dict(interface='loopback0', admin_state='down')) result = self.execute_module(changed=True) - self.assertIn('interface loopback0', result['commands']) - self.assertIn('shutdown', result['commands']) + self.assertEqual(result['commands'], ['interface loopback0', 'shutdown']) def test_nxos_interface_delete(self): set_module_args(dict(interface='loopback0', state='absent'))