Closed digitalfiend64 closed 1 year ago
@digitalfiend64 I am not able to reproduce this on my setup.Please use replace state for replacing config. Please share your playbook. In my case its working fine
- name: IOS XR test ACL
hosts: iosxr
gather_facts: no
connection: network_cli
tasks:
- name: Configure ACL
cisco.iosxr.iosxr_acls:
state: replaced
config:
- afi: ipv4
acls:
- name: ACL-TEST
aces:
- destination:
host: 1.1.1.1
grant: permit
protocol: ipv4
sequence: 10
source:
any: true`
@digitalfiend64 Just to add more information. You can use overridden state also. but not merged
@digitalfiend64 any update on this?
Hello @ashwini-mhatre , I haven't received the logs yet from my customer, they were going to test again with the latest version of collection and send logs to me if the issue persists.
A question from the customer about your comment on overrideent state versus meged: Are you saying that the merged state is not supported in this module, or just not for the use-case presented here?
@digitalfiend64 Merged state is supported in module but not suitable for Usecase. Overridden or replaced is design to replace config. so it is recomnded state.
updated sample playbook to recreate
---
- name: IOSXR ACCESS LIST - BUG TESTING
hosts: all
gather_facts: no
vars:
new_acl_2:
- afi: ipv4
acls:
- name: ACL-TEST
aces:
- destination:
host: 1.1.1.30
grant: permit
protocol: ipv4
sequence: 30
source:
any: true
tasks:
- name: GET ORIGINAL access list configuration
cisco.iosxr.iosxr_command:
commands:
- show ip access-list
register: preconfig_acls
- name: APPLY access list configuration
cisco.iosxr.iosxr_acls:
state: replaced
config: "{{ new_acl_2 }}"
- name: GET NEW access list configuration
cisco.iosxr.iosxr_command:
commands:
- show ip access-list
register: postconfig_acls
- name: DISPLAY PRECONFIG
debug: var=preconfig_acls.stdout
- name: DISPLAY POSTCONFIG
debug: var=postconfig_acls.stdout
And the inventory to invoke
---
all:
children:
iosxr:
vars:
ansible_network_os: "cisco.iosxr.iosxr"
ansible_connection: "ansible.netcommon.network_cli"
hosts:
# ASR9K-01:
# ansible_host: "192.168.1.21"
# NCS55A1-01:
# ansible_host: "192.168.1.104"
# ASR9K-03:
# ansible_host: "192.168.1.27"
NCS55A1-04:
ansible_host: "192.168.1.107"
SUMMARY
cisco.iosxr.iosxr_acls module will not overwrite an ACL remark with a non-remark entry, in either
state: merged
orstate: replaced
. It will successfully overwrite a remark with another remark, or remove the remark completely in the case ofstate: replaced
when that sequence number doesn’t exist in the requested config.The issue seems to be caused at https://github.com/ansible-collections/cisco.iosxr/blob/31a8aaecbb4eb8ba042e04acd22c77fdd8c10818/plugins/module_utils/network/iosxr/config/acls/acls.py#L505
This block, for some reason is merging
have_ace
andwant_ace
, which doesn’t make sense in this case. The method _compute_commands should be called onwant_ace
alone. I’m not sure what case this _dict_merge was added for, but it appears to be causing problems. By simply deleting/commenting line 505, the module works as expected in bothstate: merged
andstate: replaced
.ISSUE TYPE
COMPONENT NAME
cisco.iosxr.iosxr_acls ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py, line 505
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
cisco 8201-32FH, firmware 7.7.2 cisco ASR9K Series ASR-9010, firmware 6.5.3 cisco NCS-5500, firmware 7.2.2
STEPS TO REPRODUCE
Attempted to use cisco.iosxr.iosxr_acls module to configure an access-list, replacing a remark with a permit or deny statement.
Example before configuration: ipv4 access-list ACL-TEST 10 remark THIS IS A REMARK
EXPECTED RESULTS
Expected configuration: ipv4 access-list ACL-TEST 10 permit ip any host 1.1.1.1
ACTUAL RESULTS
Example after configuration (no change): ipv4 access-list ACL-TEST 10 remark THIS IS A REMARK