Skip to content

Commit

Permalink
correct the idempotency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruchip16 committed Oct 27, 2024
1 parent 227afd3 commit 13106c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Remove acls
vars:
lines:
"no ipv4 access-list acl_1\nno ipv4 access-list acl_2\nno ipv4 access-list acl_3\nno ipv4 access-list acl_3\nno ipv4 access-list test_acl\nno ipv6 access-list acl6_1\nno ipv6 access-list\
"no ipv4 access-list acl_1\nno ipv4 access-list acl_2\nno ipv4 access-list acl_3\nno ipv4 access-list acl_3\nno ipv6 access-list acl6_1\nno ipv6 access-list\
\ acl6_2\nno ipv6 access-list acl6_3\n"
ignore_errors: true
ansible.netcommon.cli_config:
Expand Down
16 changes: 12 additions & 4 deletions tests/integration/targets/iosxr_acls/tests/cli/replaced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@
destination:
any: true
protocol: icmp
- name: test_acl
aces:

- sequence: 40
remark: "Deny MARTIANS"

- sequence: 60
line: "deny ipv4 10.0.0.0 0.255.255.255 any"
grant: deny
protocol: ipv4
source:
address: 10.0.0.0
wildcard_bits: 0.255.255.255
destination:
any: true

state: replaced

- name: Assert that correct set of commands were generated
Expand All @@ -61,7 +68,8 @@
- name: Assert that task was idempotent
ansible.builtin.assert:
that:
- result.commands|length == 2
- result['changed'] == false
- result.commands|length == 0

- name: Assert that before dict is correctly generated
ansible.builtin.assert:
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/targets/iosxr_acls/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ replaced:
- no 10
- 11 permit igmp host 198.51.100.130 any ttl eq 100
- 12 deny icmp any any
- ipv4 access-list test_acl
- 40 remark Deny MARTIANS
- 60 deny ipv4 10.0.0.0 0.255.255.255 any
after:
Expand Down Expand Up @@ -148,8 +147,6 @@ replaced:
sequence: 12
source:
any: true
name: acl_2
- aces:
- remark: Deny MARTIANS
sequence: 40
- destination:
Expand All @@ -160,7 +157,7 @@ replaced:
source:
address: 10.0.0.0
wildcard_bits: 0.255.255.255
name: test_acl
name: acl_2
afi: ipv4
- acls:
- aces:
Expand Down

0 comments on commit 13106c0

Please sign in to comment.