Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/fix_acls_replace_idemp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Fixed idempotency when using `replaced` state on host with multiple ACLs present.
34 changes: 17 additions & 17 deletions plugins/module_utils/network/eos/config/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,23 @@ def _state_replaced(self, want, have):
config_cmds.append(
list(itertools.chain(*cmds)),
)
if name not in ace_names:
for w_ace in want_ace:
w = [
{
"afi": afi,
"acls": [
{
"name": name,
"aces": [w_ace],
},
],
},
]
cmds = set_commands(w, have)
config_cmds.append(
list(itertools.chain(*cmds)),
)
if name not in ace_names:
for w_ace in want_ace:
w = [
{
"afi": afi,
"acls": [
{
"name": name,
"aces": [w_ace],
},
],
},
]
cmds = set_commands(w, have)
config_cmds.append(
list(itertools.chain(*cmds)),
)

if remove_cmds:
remove_cmds = list(itertools.chain(*remove_cmds))
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/eos_acls/tests/common/replaced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@

- ansible.builtin.assert:
that:
- result.changed == true
- result.commands|length == 2
- result.changed == false
- result.commands|length == 0
- ansible_facts.network_resources.acls|symmetric_difference(result.before)
== []
always:
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/modules/network/eos/fixtures/eos_acls_idempotent.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ip access-list TEST-LIST-1
10 remark test
20 permit tcp 192.0.2.0/24 any eq https log
!
ip access-list TEST-LIST-2
10 remark test
20 permit tcp 192.0.2.0/24 any eq https log
!
ip access-list TEST-LIST-3
10 remark test
20 permit tcp 192.0.2.0/24 any eq https log
!
55 changes: 55 additions & 0 deletions tests/unit/modules/network/eos/test_eos_acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,61 @@ def test_eos_acls_deletedafis(self):
commands = ["no ip access-list test1"]
self.execute_module(changed=True, commands=commands)

def test_eos_two_acls_idempotent(self):
set_module_args(
dict(
config=[
dict(
afi="ipv4",
acls=[
dict(
name="TEST-LIST-1",
aces=[
dict(
sequence="10",
remark="test",
),
dict(
sequence="20",
grant="permit",
source=dict(subnet_address="192.0.2.0/24"),
destination=dict(
any="true",
port_protocol=dict(eq="https"),
),
protocol="tcp",
log="true",
),
],
),
dict(
name="TEST-LIST-2",
aces=[
dict(
sequence="10",
remark="test",
),
dict(
sequence="20",
grant="permit",
log="true",
destination=dict(
any="true",
port_protocol=dict(eq="https"),
),
protocol="tcp",
source=dict(subnet_address="192.0.2.0/24"),
),
],
),
],
),
],
state="replaced",
),
)
self.execute_module(changed=False, commands=[], filename="eos_acls_idempotent.cfg")

def test_eos_acls_gathered(self):
set_module_args(dict(config=[], state="gathered"))
result = self.execute_module(
Expand Down