Skip to content

Add build-time test for ansible variable conflicts#14347

Draft
ggbecker wants to merge 1 commit intoComplianceAsCode:masterfrom
ggbecker:add-unique-ansible-variables-test
Draft

Add build-time test for ansible variable conflicts#14347
ggbecker wants to merge 1 commit intoComplianceAsCode:masterfrom
ggbecker:add-unique-ansible-variables-test

Conversation

@ggbecker
Copy link
Member

@ggbecker ggbecker commented Jan 30, 2026

Description:

  • This commit adds a new CTest that checks rendered ansible files for variable naming conflicts between registered variables and rule IDs.

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:

  1. build//fixes/ansible/ - Individual rule remediations after template expansion
  2. build/ansible/-playbook-*.yml - Per-profile playbooks with fully rendered content

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:

  • Make ansible variables and rule ids unique
  • This code has been written with AI assistance

Review Hints:

  • ./build_product rhel9
  • ctest -j2 -R ansible-variable-conflicts-rhel9 --output-on-failure

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_state was 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

This commit adds a new CTest that checks rendered ansible files for
variable naming conflicts between registered variables and rule IDs.

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:
1. build/<product>/fixes/ansible/ - Individual rule remediations after
   template expansion
2. build/ansible/<product>-playbook-*.yml - Per-profile playbooks with
   fully rendered content

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-<product>' that runs automatically during
ctest execution and is labeled as a 'quick' test.
@ggbecker ggbecker added this to the 0.1.80 milestone Jan 30, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Jan 30, 2026
@openshift-ci
Copy link

openshift-ci bot commented Jan 30, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions
Copy link

ATEX Test Results

Test artifacts have been submitted to Testing Farm.

Results: View Test Results
Workflow Run: View Workflow Details

This comment was automatically generated by the ATEX workflow.

@Mab879 Mab879 self-assigned this Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants