diff --git a/lib/ansible/modules/network/ios/ios_interface.py b/lib/ansible/modules/network/ios/ios_interface.py index 39d52c6a8ec..d3a9cd468ed 100644 --- a/lib/ansible/modules/network/ios/ios_interface.py +++ b/lib/ansible/modules/network/ios/ios_interface.py @@ -385,10 +385,12 @@ def check_declarative_intent_params(module, want, result): if item.startswith('Port Description:'): have_port.append(item.split(':')[1].strip()) for item in want_neighbors: - if item['host'] not in have_host: - failed_conditions.append('host ' + item['host']) - if item['port'] not in have_port: - failed_conditions.append('port ' + item['port']) + host = item.get('host') + port = item.get('port') + if host and host not in have_host: + failed_conditions.append('host ' + host) + if port and port not in have_port: + failed_conditions.append('port ' + port) return failed_conditions