Skip to content

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Dec 24, 2025

A completely rewritten 'netlab config' command combines the 'generate configlets with built-in code' approach used with 'netlab initial' with the existing Ansible playbooks to deploy rendered config files -- an approach that works well with broken networking modules "introduced" in Ansible 12.

@ipspace
Copy link
Owner Author

ipspace commented Dec 24, 2025

As before: adding reviewers in case someone feels bored and wants to look at some code.

Will run the full integration tests before merging it.

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 completely rewrites the 'netlab config' command to address compatibility issues with Ansible 12+ by combining built-in config generation (similar to 'netlab initial') with existing Ansible playbooks for deployment. This hybrid approach works around broken networking modules in newer Ansible versions.

  • Refactored config deployment to generate configuration files internally before using Ansible
  • Added support for limiting operations to specific nodes via --limit flag
  • Implemented configuration reload functionality using saved device configurations

Reviewed changes

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

File Description
netsim/cli/config.py Complete rewrite of the config command implementation with new helper functions for node file creation, config reload, and custom config deployment
tests/platform-integration/config/04-reload.yml New integration test for configuration reload functionality with OSPF removal and restoration
tests/platform-integration/config/02-config.yml New integration test covering various device configuration mechanisms across different providers and device types

cfg_name = args.template
if '/' in cfg_name: # Custom config specified as a path to directory
cfg_path = Path(cfg_name).absolute().resolve()
if not cfg_path.exists(): # Does the specified path exists?
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error message says "Does the specified path exists?" which should be "Does the specified path exist?" - 'exists' should be 'exist' for grammatical correctness.

Suggested change
if not cfg_path.exists(): # Does the specified path exists?
if not cfg_path.exists(): # Does the specified path exist?

Copilot uses AI. Check for mistakes.
try:
run_config(cli_args)
except KeyboardInterrupt:
external_commands.interrupted('netlab initial')
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error message references 'netlab initial' but should reference 'netlab config' to match the actual command being interrupted.

Suggested change
external_commands.interrupted('netlab initial')
external_commands.interrupted('netlab config')

Copilot uses AI. Check for mistakes.
log.repeat_warnings('netlab config')

"""
We need a wrapper around the actual "run" function to catch they user interrupts
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The function comment uses 'they' which should be 'the' - there's a typo in the word 'they'.

Suggested change
We need a wrapper around the actual "run" function to catch they user interrupts
We need a wrapper around the actual "run" function to catch the user interrupts

Copilot uses AI. Check for mistakes.
A completely rewritten 'netlab config' command combines the 'generate
configlets with built-in code' approach used with 'netlab initial' with
the existing Ansible playbooks to deploy rendered config files -- an
approach that works well with broken networking modules "introduced" in
Ansible 12.
'netlab config' used to pass the '-e' parameter to the Ansible
playbook. That approach no longer works after we started rendering the
Jinja2 templates in netlab.

This commit parses '-e' parameters in 'netlab config' command and adds
extra variables to node data, making them available in custom config
templates.

Other minor fixes:

* Refactor common Ansible args processing into shared functions
* Check that no extra vars are specified on config reload
* Remove an unneeded call to set_custom_config
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