-
Notifications
You must be signed in to change notification settings - Fork 66
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
"Simulated" vyos configuration parsing #190
base: main
Are you sure you want to change the base?
Conversation
f93e9a3
to
66ef326
Compare
Looking at the test failures - I misunderstood the purpose of the ! when setting the encrypted password. I thought of it as a "not shown here for security reasons", but apparently it is used by vyos to indicate "no password" because I can see the hashes when a password is set. |
I settled with a special value of |
This comment has been minimized.
This comment has been minimized.
8912037
to
cdd8ec0
Compare
recheck |
1 similar comment
recheck |
I'm sorry, I cannot figure out why the pipeline fails the way it does with my changes, maybe some side-effect that I am completely unaware of. It did pass after pushing my last commit, but apparently not so much anymore... |
@lucaelin Thanks for working on this. Sorry for the late response. We are reviewing the PR and shall update you with our comments next week. |
recheck |
It would be really great if this could find its way into the module, it would greatly improve the usefulnesses for us! |
Hi @lucaelin, Sorry for the very delayed response. I pulled the changes and tried out a playbook. The behavior seems similar to |
Hey @GomathiselviS,
the match=smart can act the way that overridden does for resource modules, yes. This PR covers the missing functionality of
I think that the resource modules have a very different workflow or approach than the config module does, so using resource modules instead of directly deploying the configuration as a whole is not much of a viable approach for me. I also think that this discussion is beyond the scope of this PR and more of a discussion about the usability of the config module in general.
They are removed, if the provided configuration does not contain a ... # this line keeps all entries like firewall, interface, system
service {
... # this line keeps dhcp, dns
# but the next block ensures that any configuration to the ssh entry is removed and only disable-password-authentication remains
ssh {
disable-password-authentication
}
} More importantly, the smart option improves idempotency. The order in which commands appear is irrelevant and the implemented algorithm ensures that the minimal amount of changes is being made on the target in order to reach the desired state. This can be helpful in commit histories on the target and in check-mode.
I will do so as soon as I can, I hope my explanations above help to outline my motivation for this PR. |
@lucaelin Thanks for the detailed explanation. Please add examples, so that I can take this PR to my team and get their feedback. Meanwhile, I tried the following with your changes
The result was
The hostname config is deleted and set. IMO, the delete operation can be skipped, when we have the same parameter in want and have with different values. What do you think about it? I also feel that 'smart' is not the proper name when the operation this does is to replace the device configs with given configs. |
That is correct for the host-name, but not for every property. E.g. the address property for an ethernet interface. While it would certainly be possible to add knowledge about each individual property to the code, this also greatly increases complexity and requires continuous maintenance with versions changing and would also cause incompatibilities with custom extensions that are installed on the target system. IMHO, these downsides outweigh the benefits of an even cleaner diffing.
I agree. But this option is not the only option aiming to replace the config. The |
Thank you @lucaelin for extending this to improve idempotency. I have currently to generate Is there something blocking @GomathiselviS to get this rolling? |
SUMMARY
I added a new 'smart' match type to the vyos_config module. It aims to provide better configuration diffing and more reliably provisioning of devices to a given state. This is accomplished by using a new VyOS configuration simulation class. It is useful when using templated configurations while still maintaining a minimal list of changes in the Ansible output.
Fixes #179
ISSUE TYPE
ADDITIONAL INFORMATION
The new diffing algorithm is enabled by setting the
match
argument in thevyos_config
module tosmart
.I also changed the encryped password filter to require an exclamation mark at the end.With the new diffing algorithm the value"!"...
has the special meaning "keep all the existing keys as is". Please let me know if this is a reasonable change to make!I wasn't able to run the full test suit with my changes in place because I have little experience with python and python tooling. Because of this, feel free to call out inaccuracies of potential issues with the code that I didn't spot.