Skip to content

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Jan 17, 2026

This commit implements Ansible-free configuration of FRR containers. Unfortunately, the trivial implementation (devices.frr.clab.config_mode, add shebang to config templates) would break custom config templates, so we had to go for a more complex solution:

  • Add 'netlab_config_wrapper' group variable -- a Jinja2 template that is used as a generic post-processing phase for device configs
  • Use that wrapper deep in the bowels of templating code to generate valid scripts out of existing FRR configuration templates

Further FRR changes:

  • The 'netlab_mgmt_vrf' variable is not changed based on the presence of the VRF module; the 'can we use VRFs' test is moved into the initial configuration bash script.
  • FRR daemons need a bit of time to start, but it's hard to figure out when exactly they're ready. As a hack, "sleep 1" command (specified in netlab_config_exec) is added to clab.exec list by the clab provider whenever the netlab_config_mode is set

Other changes:

  • clab.config_templates is enforced to be a dict
  • Timing of a few integration tests had to be tweaked because FRR is configured earlier/faster than before

This commit implements Ansible-free configuration of FRR containers.
Unfortunately, the trivial implementation (devices.frr.clab.config_mode,
add shebang to config templates) would break custom config templates,
so we had to go for a more complex solution:

* Add 'netlab_config_wrapper' group variable -- a Jinja2 template that
  is used as a generic post-processing phase for device configs
* Use that wrapper deep in the bowels of templating code to generate
  valid scripts out of existing FRR configuration templates

Further FRR changes:

* The 'netlab_mgmt_vrf' variable is not changed based on the presence
  of the VRF module; the 'can we use VRFs' test is moved into the
  initial configuration bash script.
* FRR daemons need a bit of time to start, but it's hard to figure out
  when exactly they're ready. As a hack, "sleep 1" command (specified
  in netlab_config_exec) is added to clab.exec list by the clab
  provider whenever the netlab_config_mode is set

Other changes:

* clab.config_templates is enforced to be a dict
* Timing of a few integration tests had to be tweaked because
  FRR is configured earlier/faster than before
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements Ansible-free configuration for FRR containers using shell scripts executed by containerlab. The implementation introduces a netlab_config_wrapper mechanism to transform FRR configuration templates into executable shell scripts, and moves VRF module availability checks from configuration-time to runtime.

Changes:

  • Introduced netlab_config_wrapper group variable for post-processing device configurations with a Jinja2 template
  • Modified FRR container configuration to use runtime checks for VRF kernel module availability
  • Enforced clab.config_templates to be a dict type for consistency
  • Added sleep 1 exec command to FRR containers to allow daemons to start before configuration
  • Adjusted integration test wait times for BGP AF activation due to faster container startup

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
netsim/utils/templates.py Added render_wrapper function to apply config wrappers and integrated it into write_template
netsim/providers/clab.py Simplified config mode logic to use get_node_group_var and added exec command handling
netsim/providers/clab.yml Changed config_templates attribute type from untyped to dict
netsim/devices/frr.yml Added config wrapper template, config mode, and exec command for FRR containers
netsim/ansible/templates/initial/frr.j2 Changed VRF management logic to runtime checks instead of configuration-time checks
netsim/ansible/templates/vlan/frr.j2 Added set -x for command tracking during troubleshooting
tests/integration/wait_times.yml Added bgp_af_activate wait time of 5 seconds
tests/integration/evpn/13-vxlan-ebgp-allowas.yml Added wait times for BGP AF activation checks
tests/integration/bgp/20-dual-stack-activate.yml Added wait times for BGP AF activation checks
tests/topology/input/clab-attributes.yml Updated test to disable config mode and use dict for config_templates
tests/topology/expected/*.yml Updated test expectations to reflect new config structure with scripts, binds, and exec commands

…late

The 'netlab_config_wrapper' should not apply the script header
(shebang) to config files and hosts file. To make that happen, we have
to pass the 'mode' from the config_template list all the way to
render_config_template
ipspace added a commit that referenced this pull request Jan 17, 2026
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