diff --git a/lib/ansible/module_utils/network/ios/config/interfaces/interfaces.py b/lib/ansible/module_utils/network/ios/config/interfaces/interfaces.py index d5e23d283e9..352b6fe230f 100644 --- a/lib/ansible/module_utils/network/ios/config/interfaces/interfaces.py +++ b/lib/ansible/module_utils/network/ios/config/interfaces/interfaces.py @@ -17,7 +17,7 @@ __metaclass__ = type from ansible.module_utils.network.common.cfg.base import ConfigBase from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.ios.facts.facts import Facts -from ansible.module_utils.network.ios.utils.utils import get_interface_type, dict_diff +from ansible.module_utils.network.ios.utils.utils import get_interface_type, dict_to_set from ansible.module_utils.network.ios.utils.utils import remove_command_from_config_list, add_command_to_config_list from ansible.module_utils.network.ios.utils.utils import filter_dict_having_none_value, remove_duplicate_interface @@ -234,8 +234,8 @@ class Interfaces(ConfigBase): interface = 'interface ' + want['name'] # Get the diff b/w want and have - want_dict = dict_diff(want) - have_dict = dict_diff(have) + want_dict = dict_to_set(want) + have_dict = dict_to_set(have) diff = want_dict - have_dict if diff: diff --git a/lib/ansible/module_utils/network/ios/utils/utils.py b/lib/ansible/module_utils/network/ios/utils/utils.py index 7e89fd60df2..3b1272c4566 100644 --- a/lib/ansible/module_utils/network/ios/utils/utils.py +++ b/lib/ansible/module_utils/network/ios/utils/utils.py @@ -27,7 +27,7 @@ def add_command_to_config_list(interface, cmd, commands): commands.append(cmd) -def dict_diff(sample_dict): +def dict_to_set(sample_dict): # Generate a set with passed dictionary for comparison test_dict = {} for k, v in iteritems(sample_dict): diff --git a/lib/ansible/modules/network/ios/ios_interfaces.py b/lib/ansible/modules/network/ios/ios_interfaces.py index ba946c095cd..f205ede1830 100644 --- a/lib/ansible/modules/network/ios/ios_interfaces.py +++ b/lib/ansible/modules/network/ios/ios_interfaces.py @@ -43,6 +43,8 @@ description: This module manages the interface attributes of Cisco IOS network d author: Sumit Jaiswal (@justjais) notes: - Tested against Cisco IOSv Version 15.2 on VIRL +- This module works with connection C(network_cli). + See L(IOS Platform Options,../network/user_guide/platform_ios.html). options: config: description: A dictionary of interface options @@ -273,12 +275,12 @@ EXAMPLES = """ # duplex auto # speed auto # interface GigabitEthernet0/2 -# description Configured and Overridden by Ansible Network +# description Configured by Ansible Network # no ip address # duplex auto # speed 1000 # interface GigabitEthernet0/3 -# description Configured and Replaced by Ansible Network +# description Configured by Ansible Network # mtu 2500 # no ip address # shutdown @@ -289,7 +291,6 @@ EXAMPLES = """ ios_interfaces: config: - name: GigabitEthernet0/2 - - name: GigabitEthernet0/3 state: deleted # After state: @@ -305,9 +306,12 @@ EXAMPLES = """ # duplex auto # speed auto # interface GigabitEthernet0/3 +# description Configured by Ansible Network +# mtu 2500 # no ip address -# duplex auto -# speed auto +# shutdown +# duplex full +# speed 1000 # Using Deleted without any config passed #"(NOTE: This will delete all of configured resource module attributes from each configured interface)" @@ -321,12 +325,12 @@ EXAMPLES = """ # duplex auto # speed auto # interface GigabitEthernet0/2 -# description Configured and Overridden by Ansible Network +# description Configured by Ansible Network # no ip address # duplex auto # speed 1000 # interface GigabitEthernet0/3 -# description Configured and Replaced by Ansible Network +# description Configured by Ansible Network # mtu 2500 # no ip address # shutdown