Help Enhancing EOS_Designs output #1002
-
I am able to add non-vxlan VLANs & SVIs with ease using the custom_configuration approach. My challenge is that if I want to, for example, add pim v4 sparse mode to all l3leaf interfaces on a spine, Ansible complains about recursive loop in the template. I know this is a working approach when we just rename the var to something else (so we do not apply the custom configuration logic) and debug it, the jinja based var works as planned. Example EOS_Designs output: ethernet_interfaces:
Ethernet1:
peer: Leaf-CAMPUS-1-a
peer_interface: Ethernet1
peer_type: l3leaf
description: P2P_LINK_TO_Leaf-CAMPUS-1-a_Ethernet1
mtu: 1500
type: routed
shutdown: false
ip_address: 10.0.255.8/31
Ethernet2:
peer: Leaf-CAMPUS-1-b
peer_interface: Ethernet1
peer_type: l3leaf
description: P2P_LINK_TO_Leaf-CAMPUS-1-b_Ethernet1
mtu: 1500
type: routed
shutdown: false
ip_address: 10.0.255.12/31
Ethernet3:
peer: Leaf-CAMPUS-2-a
peer_interface: Ethernet1
peer_type: l3leaf
description: P2P_LINK_TO_Leaf-CAMPUS-2-a_Ethernet1
mtu: 1500
type: routed
shutdown: false
ip_address: 10.0.255.16/31
Ethernet4:
peer: Leaf-CAMPUS-2-b
peer_interface: Ethernet1
peer_type: l3leaf
description: P2P_LINK_TO_Leaf-CAMPUS-2-b_Ethernet1
mtu: 1500
type: routed
shutdown: false
ip_address: 10.0.255.20/31 Example custom_structured_configuration_ethernet_interfaces custom_structured_configuration_ethernet_interfaces: "{%- set temp_interface_dict = {} -%}
{%- for interface in ethernet_interfaces | dict2items| selectattr('value.peer_type', 'equalto', 'l3leaf') -%}
{%- set _ = temp_interface_dict.update( {interface['key']: (interface['value'] | combine ({'pim':{'ipv4': {'sparse_mode': true}}})) } ) -%}
{%- endfor -%}
{{- temp_interface_dict -}}" @carlbuchmann recently suggested my hacks put in place deserved to be properly addressed in the eos_designs model. The more I look at this, the more I think, similar to #995 this should be an option in the design to allow for pim to be applied to uplinks & ibgp peer links. Yes PIM is multicast is still very much a work in progress in EVPN, BUT that does not mean people do not setup multicast/pim in their underlay. Any other suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
@ryanmerolle, in our chat, I was referring to extending with adding your own template to the "stack" with yaml_template_to_facts https://avd.sh/en/latest/plugins/#yaml-templates-to-facts templates:
# Templates defined per design
l3ls-evpn:
facts:
# Set general "switch.*" variables
- template: "facts/main.j2"
# Set design specific "switch.*" variables
- template: "designs/l3ls-evpn/facts/main.j2"
structured_config:
# Render Structured Configuration
# Base features
- template: "base/main.j2"
# MLAG feature
- template: "mlag/main.j2"
# Underlay feature
- template: "designs/l3ls-evpn/underlay/main.j2"
# Overlay feature
- template: "designs/l3ls-evpn/overlay/main.j2"
# L3 Edge feature
- template: "l3_edge/main.j2"
# Tenants feature
- template: "designs/l3ls-evpn/tenants/main.j2"
# Connected Endpoints feature
- template: "connected_endpoints/main.j2"
# Merge custom_structured_configuration last
- template: "custom-structured-configuration-from-var.j2"
options:
list_merge: "{{ custom_structured_configuration_list_merge }}"
strip_empty_keys: false
### Ryan's custom templates ###
# Add PIM multicast configuration
- template: "custom-ethernet-interface-configuration.j2" |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hi Ryan
I believe your example does not work, because there is no variable
ethernet_interfaces
at the time of the rendering. During rendering we place the structured configuration into a tmp variable calledstructured_config
so it should bestructured_config.ethernet_interfaces
, but I tried testing with that, and it seems like the rendering of the inline template happens before it is passed to our code, so evenstructured_config
is not available.It could work from the leaf standpoint by iterating over the
topology.links
facts which are set in a previous stage.Also note that you don't have to do the combine. We take care of that in the
custom_structured_configuration
code.