Enforce has_feature filter for enabled_features checks#626
Open
ehelms wants to merge 2 commits into
Open
Conversation
Replace raw 'in enabled_features' checks with the has_feature filter which correctly handles prefix matching and transitive dependencies. Add a custom ansible-lint rule to prevent regressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Why are you introducing these changes? (Problem description, related links)
The
has_featureJinja2 filter handles feature membership correctly via exact match, prefix match (e.g.content/debmatchingcontent), and transitive dependency resolution. Several places in the codebase were using raw'x' in enabled_featureschecks instead, which bypasses prefix and dependency logic.What are the changes introduced in this pull request?
'x' in enabled_featureswithenabled_features | has_feature('x')acrosssrc/anddevelopment/use-has-feature-filter) to prevent regressions, checking task-levelwhenclauses, role-levelwhenclauses, and variable valuesHow to test this pull request
Steps to reproduce:
cd src && ansible-lint- should passcd development && ansible-lint- should passhas_feature('iop')back to'iop' in enabled_featuresinsrc/playbooks/deploy/deploy.yaml) and verify the rule flags itChecklist