ios_static_routes bug in compare logic
eleksis opened this issue · comments
SUMMARY
Module does not generate necessary commands to achieve desired state (missing commands). There is possibility that bug is deeper in shared/netcommon compare() function. As we still (also) have problems with IP configuration via ios_l3_interfaces module. But not sure, as code is extremely difficult to read (a lot of non-intuitive var names, no comments, etc.).
I am updating bug report, as i have found out i did not identify problem at the correct place. I thought module did not generate commands right, but as it turns out there is a problem in gathering facts (static routes) from device. Look below & compare before state from device output and before dict in module output.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ios_static_routes.py
ANSIBLE VERSION
ansible-code 2.15.8
ios collection 6.0.0
STEPS TO REPRODUCE
BEFORE:
#sh run | sec ip route
ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.33 tag 30
ip route 192.168.30.0 255.255.255.248 GigabitEthernet0/1.23 10.0.0.33 tag 30
# We want to change next-hop of first route and remove second one.
- name: Replace provided configuration with device configuration
ios_static_routes:
config:
- address_families:
- afi: ipv4
routes:
- dest: 192.168.30.0/24
next_hops:
- forward_router_address: 10.0.0.30
interface: GigabitEthernet0/1.23
tag: 30
state: replaced
EXPECTED RESULTS
EXPECTED:
#sh run | sec ip route
ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.30 tag 30
ACTUAL RESULTS
TASK [Replace provided configuration with device configuration] ***************************************************************************************************************************************************
changed: [router.example.com] => changed=true
after:
- address_families:
- afi: ipv4
routes:
- dest: 192.168.30.0/24
next_hops:
- forward_router_address: 10.0.0.33
interface: GigabitEthernet0/1.23
tag: 30
- forward_router_address: 10.0.0.30
interface: GigabitEthernet0/1.23
tag: 30
before:
- address_families:
- afi: ipv4
routes:
- dest: 192.168.30.0/29
next_hops:
- forward_router_address: 10.0.0.33
interface: GigabitEthernet0/1.23
tag: 30
- forward_router_address: 10.0.0.33
interface: GigabitEthernet0/1.23
tag: 30
commands:
- ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.30 tag 30
- no ip route 192.168.30.0 255.255.255.248 GigabitEthernet0/1.23 10.0.0.33 tag 30
#sh run | sec ip route
ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.33 tag 30
ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.30 tag 30
ADDITIONAL INFO
self.have in Static_routes already has wrong data, so bug must be in get_facts() / Static_routesFacts.
Hi @KB-perByte, saw you assigned ticket to yourself. Is this in progress right now? Otherwise i will look into it.
@eleksis not actively looking at this, we would have planned it, if you want to add a contribution for the fix. We would be more than happy to review and merge the contribution.
Thank you!