-
Notifications
You must be signed in to change notification settings - Fork 99
netlab config: Add support for Ansible 12+ #2968
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
base: dev
Are you sure you want to change the base?
Conversation
|
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. |
There was a problem hiding this 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
--limitflag - 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 |
netsim/cli/config.py
Outdated
| 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? |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
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.
| if not cfg_path.exists(): # Does the specified path exists? | |
| if not cfg_path.exists(): # Does the specified path exist? |
netsim/cli/config.py
Outdated
| try: | ||
| run_config(cli_args) | ||
| except KeyboardInterrupt: | ||
| external_commands.interrupted('netlab initial') |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
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.
| external_commands.interrupted('netlab initial') | |
| external_commands.interrupted('netlab config') |
netsim/cli/config.py
Outdated
| log.repeat_warnings('netlab config') | ||
|
|
||
| """ | ||
| We need a wrapper around the actual "run" function to catch they user interrupts |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
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'.
| 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 |
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.
0a4362e to
e451a03
Compare
'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
a80a3f9 to
f994393
Compare
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.