Skip to content

Fix: Recognize a.b or a/b in included VyOS dataplane templates#3587

Merged
ipspace merged 1 commit into
devfrom
vyos-initial-plugins
Jul 7, 2026
Merged

Fix: Recognize a.b or a/b in included VyOS dataplane templates#3587
ipspace merged 1 commit into
devfrom
vyos-initial-plugins

Conversation

@ipspace

@ipspace ipspace commented Jul 6, 2026

Copy link
Copy Markdown
Owner

VyOS initial device configuration includes interface configuration code from plugin configuration templates. The plugin name in the node data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas the new directory structure uses slashes (i.e. 'tunnel/gre').

This fix tries both names to allow users to override plugin dataplane templates in their own 'tunnel.gre' directory.

VyOS initial device configuration includes interface configuration
code from plugin configuration templates. The plugin name in the node
data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas
the new directory structure uses slashes (i.e. 'tunnel/gre').

This fix tries both names to allow users to override plugin dataplane
templates in their own 'tunnel.gre' directory.
@ipspace ipspace requested a review from ssasso July 6, 2026 15:49
@ipspace

ipspace commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

@ssasso -- Are you OK if I extend the same approach to VLANs and VRFs? That would clean up the "initial" directory.

@ssasso

ssasso commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@ssasso -- Are you OK if I extend the same approach to VLANs and VRFs? That would clean up the "initial" directory.

Yes please

{% set dp_initial = x_dp + '/vyos.initial.j2' %}
{% set dp_alt = x_dp.replace('.','/') + '/vyos.initial.j2' %}
{% include [ dp_initial, dp_alt ] ignore missing %}
{% endfor %}

@jbemmel jbemmel Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

{% for x_dp in config|default([]) %}
{%   for dir in [ x_dp, x_dp.replace('.', '/') ] %}
{%     include dir + '/vyos.initial.j2' ignore missing %}
{%   endfor %}
{% endfor %}```

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

... and if the server behaves as weirdly as mine does, you'll get two copies of the same config commands. That's why I went for a list in the "include" directive.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Understood, in that case:

{% macro include_plugin_initial_configs(device_name) -%}
  {% set template = '/' + device_name + '.initial.j2' %}
  {% for x_dp in config|default([]) %}
    {% include [ x_dp + template, x_dp.replace('.', '/') + template ] ignore missing %}
  {% endfor %}
{%- endmacro %}

so we can use it for frr too?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

You're reading my mind. The next step will be a generic (macro) solution that will work with all devices, and I'll use it to clean up a few VLAN/VRF templats.

However, I still think we don't need it for FRR ;)) but we already have that discussion in #3585

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

However, I still think we don't need it for FRR ;)) but we already have that discussion in #3585

I guess I'll have to disagree on multiple fronts then, perhaps it's more effective that way ;)

@ipspace

ipspace commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Yes please

Will do after merging this one. Does it work for you?

@ssasso

ssasso commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Yes please

Will do after merging this one. Does it work for you?

Yes absolutely, no problem

@ipspace ipspace merged commit 36c3a12 into dev Jul 7, 2026
@ipspace ipspace deleted the vyos-initial-plugins branch July 7, 2026 10:28
snuffy22 pushed a commit to snuffy22/netlab that referenced this pull request Jul 9, 2026
…ce#3587)

VyOS initial device configuration includes interface configuration
code from plugin configuration templates. The plugin name in the node
data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas
the new directory structure uses slashes (i.e. 'tunnel/gre').

This fix tries both names to allow users to override plugin dataplane
templates in their own 'tunnel.gre' directory.
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.

3 participants