Add build-time test for ansible variable conflicts #14347
Draft
+283
−0
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.
Description:
The problem occurs when ansible remediations register a variable with the same name as a rule ID. For example, if rule 'selinux_state' uses 'register: selinux_state', this creates a conflict with the 'selinux_state' boolean control variable used in when conditions like 'when: selinux_state | bool'. This causes the task to be skipped since the variable shadows the control variable, preventing proper execution.
The test checks two locations in the build directory:
The test runs for each product during the build and will fail if any registered variable name matches any rule ID in the system, ensuring that such conflicts are caught early in development.
This is integrated into the cmake build system as a new test target 'ansible-variable-conflicts-' that runs automatically during ctest execution and is labeled as a 'quick' test.
Rationale:
Review Hints:
Concerns
The test takes about 17 seconds to run on my machine for a single product, I would introduce a lot of overhead to the CTest execution. So I don't know if it would make sense to introduce such a test. The
selinux_statewas the only case that ever happened.If we have an easy way to integrate this into the build system as a build step, maybe it wouldn't be so inefficient. Please share your suggestions.
Related to: #14346