From 98f3424ed0e4c3a4e1e95e9f3950f4e57e3ca74e Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Mon, 25 Dec 2017 18:11:35 +0530 Subject: [PATCH] Fix ios_l3_interface configure ipv4 address issue (#34222) Adding a new interface and it's ipv4/ipv6 address results in failure. Add a check to validate if interface address is already configured or not. --- lib/ansible/modules/network/ios/ios_l3_interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/ios/ios_l3_interface.py b/lib/ansible/modules/network/ios/ios_l3_interface.py index a43605f060f..f8dcc3ac1fb 100644 --- a/lib/ansible/modules/network/ios/ios_l3_interface.py +++ b/lib/ansible/modules/network/ios/ios_l3_interface.py @@ -185,14 +185,14 @@ def map_obj_to_commands(updates, module): elif state == 'present': if ipv4: - if obj_in_have is None or ipv4 != obj_in_have['ipv4']: + if obj_in_have is None or obj_in_have.get('ipv4') is None or ipv4 != obj_in_have['ipv4']: address = ipv4.split('/') if len(address) == 2: ipv4 = '{0} {1}'.format(address[0], to_netmask(address[1])) commands.append('ip address {}'.format(ipv4)) if ipv6: - if obj_in_have is None or obj_in_have['ipv6'] is None or ipv6.lower() != obj_in_have['ipv6'].lower(): + if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() != obj_in_have['ipv6'].lower(): commands.append('ipv6 address {}'.format(ipv6)) if commands[-1] == interface: