diff --git a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py index 5bd15062e..dcf4c3b0c 100644 --- a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py @@ -10,6 +10,7 @@ necessary to bring the current configuration to it's desired end-state is created """ + from __future__ import absolute_import, division, print_function @@ -120,7 +121,7 @@ def set_config(self, existing_acl_interfaces_facts): for w in config: if get_interface_type(w["name"]) == "loopback": self._module.fail_json( - msg="This module works with ethernet, management or port-channe", + msg="This module works with ethernet, management or port-channel.", ) w.update({"name": normalize_interface(w["name"])}) want.append(remove_empties(w)) @@ -139,7 +140,9 @@ def set_state(self, want, have): """ if self.state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state), + msg="value of config parameter must not be empty for state {0}".format( + self.state, + ), ) commands = [] @@ -185,7 +188,11 @@ def _state_replaced(self, want, have): for ag in obj_in_have["access_groups"]: want_afi = [] if want.get("access_groups"): - want_afi = search_obj_in_list(ag["afi"], want["access_groups"], "afi") + want_afi = search_obj_in_list( + ag["afi"], + want["access_groups"], + "afi", + ) if not want_afi: # whatever in have is not in want del_dict["access_groups"].append(ag) @@ -241,7 +248,11 @@ def set_commands(self, want, have, deleted=False): ip = "ipv6" if w_afi["afi"] == "ipv4": ip = "ip" - have_afi = search_obj_in_list(w_afi["afi"], have_name["access_groups"], "afi") + have_afi = search_obj_in_list( + w_afi["afi"], + have_name["access_groups"], + "afi", + ) if have_afi: new_acls = [] if deleted: diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml index 3cad7ce53..f76058818 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml @@ -22,6 +22,7 @@ - name: Remove configuration - 3 cisco.nxos.nxos_config: lines: + - no switchport - no ip access-group ACL1v4 out parents: interface Ethernet1/3 ignore_errors: true @@ -41,3 +42,8 @@ - no ip port access-group PortACL in parents: interface Ethernet1/6 ignore_errors: true + +- name: Remove configuration - 6 + cisco.nxos.nxos_config: + lines: no interface loopback1 + ignore_errors: true diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml index 90f72fb39..d42b4b19a 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml @@ -83,6 +83,9 @@ - "'no ip port access-group PortACL in' in result.commands" - "'ipv6 port traffic-filter NewACLv6 in' in result.commands" + - ansible.builtin.debug: + msg: "{{ ansible_facts['network_resources']['acl_interfaces'] }}" + - name: Revert back to base configuration using facts round trip register: result cisco.nxos.nxos_acl_interfaces: