feat: take every var when a declarative enricher names no fields - #218
Merged
Conversation
Being in a group carries all of that group's vars in Ansible -- there is no per-name permission -- so fields is the narrowing and its absence should mean the ordinary thing rather than the empty one. It meant the empty one. An enricher with a source_id, a target_id and no fields ran, copied nothing and reported success: a config that looks active and is not. fields: [] is unchanged and still takes nothing. An explicitly empty list names nothing, which is a different statement from not naming any. Omitting fields hands the target everything the matching groups hold, including whatever sits beside the variable that was wanted. An endpoint's exclude_vars can drop a name on the way out, but it does not narrow what was written into the target source itself.
It said 'which top-level hostvars keys to copy from source', which stopped being true twice: 0.26.0 made it govern a group's vars as well, and this change makes its absence mean every var rather than none.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
fieldson a declarative enricher is a narrowing. Its absence meant the empty set, not the full one: an enricher with asource_id, atarget_idand nofieldsran, copied nothing, and reported success. A config that looks active and is not.That is also not how the thing it models behaves. Being in a group carries all of that group's vars in Ansible — there is no per-name permission, and nobody writing
group_vars/<group>/x.yamlexpects a consumer to take one key from the file and refuse another.The change
Absent
fieldsnow takes every var the source declares — on a matching group, onall, and on a matching host.fields: []is unchanged and still takes nothing. An explicitly empty list names nothing, which is a different statement from not naming any, and the two now mean different things rather than the same thing.What this does not change
No host crosses between sources. Taking every var is not taking hosts — the target's host set is untouched, which is the property that makes an enricher usable where widening an endpoint's
source_idsis not.Consequences, stated plainly
Omitting
fieldshands the target everything the matching groups hold, including whatever sits beside the variable that was wanted. An endpoint'sexclude_varscan drop a name on the way out — it covers group vars since 0.25.0 — but it does not narrow what the enricher wrote into the target source itself. Documented indocs/enrichers.md.Verification
cargo fmt --checkclean,clippy --all-targets -- -D warningsclean, 585 tests. Two new, each red before the change: one for absent-means-everything, one pinningfields: []as distinct from absent.Beyond the suite, the real image was built with podman and run against real data — a 1097-host inventory with 305 vars on
all, enriching a 780-host Device42 replay, with the enricher declaring nofields:That last line is the point of the design: everything travels, and it travels once, on the group.
--check-configalso passes inside the image against all five real deployment configs.