Skip to content
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

T6837 / #288 support for replace in vyos_config module #361

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mrvantage
Copy link

@mrvantage mrvantage commented Nov 17, 2024

Change Summary

T6837 / #288 Implemented replace functionality using a boolean arg for the module. Also Improved detection of config lines already present on router, and filter them out in calculated diff

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Other (please describe):
    Adjustment of filter logic, to filter out lines already present on router. This to only push changes to router, and avoid setting config that is in place already.

Related Task(s)

T6837

Related PR(s)

n/a

Proposed changes

  • Add boolean replace argument to the vyos_config ansible module
  • This argument is set to false by default, for backward compatibility
  • When set to true all lines from the running config

How to test

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

mrvantage added 2 commits November 17, 2024 10:34
…g for the module. Also Improved detection of config lines already present on router, and filter them out in calculated diff
@gaige
Copy link
Contributor

gaige commented Nov 17, 2024

@mrvantage Thanks so much for the contribution. Can you add unit tests for this PR, please? Specifically testing each new route through the code and any variations (such as error cases and the quote misalignments).

Unit tests for vyos_config are located in tests/unit/modules/network/vyos/test_vyos_config.py and there are some good examples in there.

  • Add tests
  • Add file to changelogs/fragments representing this change
  • Confirm the versions you've been able to test on for integration tests

@mrvantage
Copy link
Author

Yes, I think this definitely requires some proper unit tests. I already found an issue with my proposed implementation. This doesn't cover the situation where deleting config lines leaves a group without any sub settings. This could lead to invalid configuration, and there's no nice way of cleaning this up in replace mode.

For example, when removing a wireguard peer from the config maintained in ansible, the peer remains without any settings on the router, which is invalid.

I need to come up with a solution for this first. If I manage, I will look at writing some unit tests to cover these kind of situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants