recursive connection_options with merged extra
support
#761
viktorkertesz
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear Nornir community,
I'm curious about your opinion on the following matter:
Problem
Currently
connection_options.extras
is a dict and the logic to access this attribute is that Host objectextras
is the top priority and then Group and Defaults follows. Theextras
attribute is simply overwritten in more specific configuration. However it would be nice to have this attribute as a merge of all the otherextras
defined in Host, Group and Defaults instances.Possible solution logic
*First, I'd like to highlight that this behavior changes the API and must be communicated and use in upcoming main version!*
get_connection_options
logic in a way that defaults, group and host connection_options.extra parameters would be merged. Priority is defaults -> group1, group2,... -> hostSo a host defined extra parameter would override defaults or groups if the key is the same. All distinct parameters will be merged together.
None
value would do the trick.Benefits
We can better segment our
connection_options
extra parameters. We can define partialextras
in defaults, groups and hosts.Downside of the new logic
If a user relies on that host defined extra will not merge but replace the default/groups, then the user might get additional parameters which might be unexpected.
Example
defaults.yaml:
groups.yaml:
hosts.yaml:
Old behavior
This will result in that host1 will NOT have the secret parameter nor the timeout value. Host file replace the extras.
New behavior
host1 will have set the port 222, timeout of 4s and the secret set as well. Host file will merge the extras.
TODO
Beta Was this translation helpful? Give feedback.
All reactions