Skip to content

Fix SELinux ansible variable name conflict#14346

Merged
Mab879 merged 1 commit intoComplianceAsCode:masterfrom
ggbecker:fix-ansible-unique-variables3
Jan 30, 2026
Merged

Fix SELinux ansible variable name conflict#14346
Mab879 merged 1 commit intoComplianceAsCode:masterfrom
ggbecker:fix-ansible-unique-variables3

Conversation

@ggbecker
Copy link
Member

Description:

The ansible remediation for both selinux_not_disabled and selinux_state rules were using 'selinux_state' as the registered variable name for the output of the 'getenforce' command. This created a naming conflict with the 'selinux_state' boolean control (which comes from the rule id) variable used in the when conditions to determine if a rule should be applied.

When roles are generated, the 'Check current SELinux state' task includes a when condition with 'selinux_state | bool' (coming from the rule id), but this creates a circular dependency since that same task is supposed to register 'selinux_state'.
As a result, the task gets skipped, the variable never gets registered, and subsequent tasks that depend on checking the current SELinux state fail or are skipped.

This fix renames the registered variable from 'selinux_state' to 'current_selinux_state' in both ansible remediation files to avoid the naming conflict.

Rationale:

The ansible remediation for both selinux_not_disabled and selinux_state
rules were using 'selinux_state' as the registered variable name for the
output of the 'getenforce' command. This created a naming conflict with
the 'selinux_state' boolean control (which comes from the rule id)
variable used in the when conditions to determine if a rule should be applied.

When roles are generated, the 'Check current SELinux state' task includes
a when condition with 'selinux_state | bool' (coming from the rule id),
but this creates a circular dependency since that same task is supposed
to register 'selinux_state'.
As a result, the task gets skipped, the variable never gets registered,
and subsequent tasks that depend on checking the current SELinux state
fail or are skipped.

This fix renames the registered variable from 'selinux_state' to
'current_selinux_state' in both ansible remediation files to avoid
the naming conflict.

Fixes: ComplianceAsCode#14344
@ggbecker ggbecker added this to the 0.1.80 milestone Jan 30, 2026
@ggbecker ggbecker added the Ansible Ansible remediation update. label Jan 30, 2026
@openshift-ci
Copy link

openshift-ci bot commented Jan 30, 2026

@ggbecker: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.16-images 566c230 link true /test 4.16-images

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@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
@Mab879 Mab879 merged commit 69218ef into ComplianceAsCode:master Jan 30, 2026
61 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ansible Ansible remediation update.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

selinux state not correct

2 participants