diff --git a/lib/ansible/modules/network/nxos/nxos_interface_ospf.py b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py index 63f42ba0d1..f415be3f73 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface_ospf.py +++ b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py @@ -296,6 +296,8 @@ def state_present(module, existing, proposed, candidate): if existing_commands[key] == proposed_commands[key]: continue + if key == 'ip ospf passive-interface' and module.params.get('interface').upper().startswith('LO'): + module.fail_json(msg='loopback interface does not support passive_interface') if value is True: commands.append(key) elif value is False: diff --git a/test/units/modules/network/nxos/test_nxos_interface_ospf.py b/test/units/modules/network/nxos/test_nxos_interface_ospf.py index 78b2b41195..7d9e9d9598 100644 --- a/test/units/modules/network/nxos/test_nxos_interface_ospf.py +++ b/test/units/modules/network/nxos/test_nxos_interface_ospf.py @@ -50,3 +50,7 @@ class TestNxosInterfaceOspfModule(TestNxosModule): def test_nxos_interface_ospf(self): set_module_args(dict(interface='ethernet1/32', ospf=1, area=1)) self.execute_module(changed=True, commands=['interface Ethernet1/32', 'ip router ospf 1 area 0.0.0.1']) + + def test_loopback_interface_failed(self): + set_module_args(dict(interface='loopback0', ospf=1, area=0, passive_interface=True)) + self.execute_module(failed=True, changed=False)