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

iosxr_route_policy - resource module #512

Merged
merged 38 commits into from
Oct 17, 2024

Conversation

KB-perByte
Copy link
Contributor

@KB-perByte KB-perByte commented Sep 25, 2024

SUMMARY

the iosxr_route_policy resource module

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

Playbook -

---
- name: Parse the provided configuration
  cisco.iosxr.iosxr_route_maps:
    running_config: "{{ lookup('file', 'iosxr_route_maps_conf.cfg') }}"
    state: parsed

Appliance config -

route-policy SIMPLE_GLOBAL_ROUTE_POLICY
  set weight 20000
  set local-preference 200
  set community (11011:1001) additive
  apply A_NEW_ROUTE_POLICY
end-policy
!
route-policy SIMPLE_CONDITION_ROUTE_POLICY
  if destination in SIMPLE_CONDITION_ROUTE_POLICY then
    pass
  else
    drop
  endif
end-policy
!
route-policy COMPLEX_ROUTE_POLICY
  if as-path in (ios-regex '_3117_', ios-regex '_600_') then
    drop
  else
    if destination in A_RANDOM_POLICY then
      pass
      set community (101010:1) additive
      set local-preference 200
    else
      drop
    endif
  endif
end-policy
!
route-policy COMPLEX_CONDITION_ROUTE_POLICY
  if community matches-any (9119:1001) or community matches-any (11100:1001) then
    drop
  else
    pass
  endif
end-policy
!
route-policy SUPER_COMPLEX_CONDITION_ROUTE_POLICY
  set ospf-metric 232
  prepend as-path most-recent 22
  if destination in DEFAULT then
    set qos-group 2
    set spf-priority critical
    set upstream-core-tree ingress-replication
  elseif destination in TEST-EXTERNAL-CONDITION0 then
    add eigrp-metric 22 223 23 223 232
    remove as-path private-as entire-aspath
  elseif destination in TEST-EXTERNAL-CONDITION1 then
    set tag 2323
    apply DUMMY-RMP-1
    apply DUMMY-RMP-2
    apply DUMMY-RMP-3
    set weight 23
  else
    set ospf-metric 232
    set qos-group 2
    set rip-tag 2
    set rt-set route-limit 22
    if destination in TEST-INTERNAL-IFCONDITION then
      unsuppress-route
    elseif destination in TEST-INTERNAL_ELIFCONDITION then
      pass
      apply DUMMY-RMP-4
      set administrative-distance 22
    elseif destination in TEST-INTERNAL-DIFFERENT or destination in DEFAULT then
      apply DUMMY-RMP-3
    else
      set ospf-metric 232
      set qos-group 2
      set rip-tag 2
      set rt-set route-limit 22
      set s-pmsi star-g
    endif
   endif
end-policy

Task Output -

TASK [Parse the provided configuration] **********************************************************************************************************************************************************************
task path: /BATMONvsSUPERMON/iosxr_route_maps.yaml:6
Monday 14 October 2024  11:01:20 +0530 (0:00:00.043)       0:00:00.043 ********
ok: [BATMON] => changed=false
  invocation:
 ...
  parsed:
  - global:
      apply:
      - route_policy: A_NEW_ROUTE_POLICY
      set:
        community:
          additive: true
          community_name: (11011:1001)
        weight: 20000
    name: SIMPLE_GLOBAL_ROUTE_POLICY
  - else_section:
      global:
        drop: true
    if_section:
      condition: destination in SIMPLE_CONDITION_ROUTE_POLICY
      pass: true
    name: SIMPLE_CONDITION_ROUTE_POLICY
  - else_section:
      else_section:
        drop: true
      if_section:
        condition: destination in A_RANDOM_POLICY
        pass: true
        set:
          community:
            additive: true
            community_name: (101010:1)
    if_section:
      condition: as-path in (ios-regex '_3117_', ios-regex '_600_')
      drop: true
    name: COMPLEX_ROUTE_POLICY
  - else_section:
      global:
        pass: true
    if_section:
      condition: community matches-any (9119:1001) or community matches-any (11100:1001)
      drop: true
    name: COMPLEX_CONDITION_ROUTE_POLICY
  - else_section:
      else_section:
        set:
          ospf_metric: 232
          qos_group: 2
          rip_tag: 2
          rt_set: 22
          s_pmsi: true
      elseif_section:
      - apply:
        - route_policy: DUMMY-RMP-4
        condition: destination in TEST-INTERNAL_ELIFCONDITION
        pass: true
        set:
          administrative_distance: 22
      - apply:
        - route_policy: DUMMY-RMP-3
        condition: destination in TEST-INTERNAL-DIFFERENT or destination in DEFAULT
      global:
        set:
          ospf_metric: 232
          qos_group: 2
          rip_tag: 2
          rt_set: 22
      if_section:
        condition: destination in TEST-INTERNAL-IFCONDITION
        unsuppress_route: true
    elseif_section:
    - add:
        eigrp_metric:
          bandwidth: 22
          delay: 223
          effective_bandwith: 223
          max_transmission: 232
          reliability: 23
      condition: destination in TEST-EXTERNAL-CONDITION0
      remove:
        entire_aspath: true
        set: true
    - apply:
      - route_policy: DUMMY-RMP-1
      - route_policy: DUMMY-RMP-2
      - route_policy: DUMMY-RMP-3
      condition: destination in TEST-EXTERNAL-CONDITION1
      set:
        tag: 2323
        weight: 23
    global:
      set:
        ospf_metric: 232
    if_section:
      condition: destination in DEFAULT
      set:
        qos_group: 2
        spf_priority:
          critical: true
        upstream_core_tree:
          ingress_replication: true
    name: SUPER_COMPLEX_CONDITION_ROUTE_POLICY

@KB-perByte
Copy link
Contributor Author

Note: We are planning to update the model if/ else/ elseif to something that is not under reserved keywords like if_condition/ else_condition/ elseif_condition.
I am not fond of it, but I am open to ideas.

@Ruchip16
Copy link
Contributor

Note: We are planning to update the model if/ else/ elseif to something that is not under reserved keywords like if_condition/ else_condition/ elseif_condition. I am not fond of it, but I am open to ideas.

did we update if/else/elseif to if_section/else_section/elseif_section, if yes then that looks good to me,but would love to hear your thoughts on this

Copy link
Contributor

@Ruchip16 Ruchip16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@KB-perByte
Copy link
Contributor Author

@Ruchip16 yep yep, we settled for if_section/ elseif_section/ else_section.
Regards

@KB-perByte KB-perByte merged commit d1d6a33 into ansible-collections:main Oct 17, 2024
48 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.

2 participants