Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Include netmask into static_routes parser as part of result key #1076

Merged

Conversation

eleksis
Copy link
Contributor

@eleksis eleksis commented May 15, 2024

Netmask is part of route destination and should be included as 'primary' key for distinguishing routes. For ipv6 it is already part of dest parameter.

SUMMARY

Fixes #1037

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ios_static_routes

ADDITIONAL INFORMATION
DEVICE BEFORE STATE:
#sh run | sec ip route
ip route 153.5.255.0 255.255.255.248 178.172.80.30
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 10.0.0.3
ip route 192.168.30.0 255.255.255.248 GigabitEthernet0/1.23 10.0.0.33 tag 30

PLAYBOOK:
    - name: Replace provided configuration with device configuration
      ios_static_routes:
        config:
          - address_families:
              - afi: ipv4
                routes:
                  - dest: 153.5.255.0/29
                    next_hops:
                      - forward_router_address: 178.172.80.30
                  - dest: 192.168.30.0/24
                    next_hops:
                      - forward_router_address: 10.0.0.30
                        interface: GigabitEthernet0/1.23
                        tag: 30
        state: replaced

OUTPUT:
TASK [Replace provided configuration with device configuration] ***************************************************************************************************************************************************
changed: [rmeereen.cpe.arnes.si] => changed=true 
  after:
  - address_families:
    - afi: ipv4
      routes:
      - dest: 153.5.255.0/29
        next_hops:
        - forward_router_address: 178.172.80.30
      - dest: 192.168.30.0/24
        next_hops:
        - forward_router_address: 10.0.0.30
          interface: GigabitEthernet0/1.23
          tag: 30
  before:
  - address_families:
    - afi: ipv4
      routes:
      - dest: 153.5.255.0/29
        next_hops:
        - forward_router_address: 178.172.80.30
      - 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.3
      - dest: 192.168.30.0/29
        next_hops:
        - 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.0 GigabitEthernet0/1.23 10.0.0.33 tag 30
  - no ip route 192.168.30.0 255.255.255.0 10.0.0.3
  - no ip route 192.168.30.0 255.255.255.248 GigabitEthernet0/1.23 10.0.0.33 tag 30

DEVICE AFTER STATE:
#sh run | sec ip route
ip route 153.5.255.0 255.255.255.248 178.172.80.30
ip route 192.168.30.0 255.255.255.0 GigabitEthernet0/1.23 10.0.0.30 tag 30

Netmask is part of route destination and should be
included as 'primary' key for distinguishing routes.
For ipv6 it is already part of dest parameter.
@KB-perByte
Copy link
Collaborator

@eleksis Thank you for working on it the fix looks good to me, can you please add a changelog describing the fix and a test (unit) for the same?
Let me know if you need any help.

Regards.

@KB-perByte KB-perByte self-requested a review May 17, 2024 05:10
@eleksis
Copy link
Contributor Author

eleksis commented May 20, 2024

@KB-perByte Hope this is ok. I extended test for 'gathered' state, as fix is related to code parsing facts. All other module states use this gathered data later on.

@roverflow roverflow merged commit 410718f into ansible-collections:main May 22, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ios_static_routes bug in compare logic
3 participants