Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stabilization]: add when conditional to Ansible remediation of sssd_enable_pam_services #11979

Conversation

vojtapolasek
Copy link
Collaborator

@vojtapolasek vojtapolasek commented May 9, 2024

Description:

  • add a when conditional so that the task replacing values in files within /etc/sssd/conf.d directory is not executed in case no files are found

Rationale:

  • older Ansible versions might terminate prematurely if there are no config files found in /etc/sssd/conf.d directory

Review Hints:

  1. provision RHEL 7 machine with official Ansible version 2.9.27
  2. ./build_product rhel7
  3. upload the stig ansible playbook to the machine
  4. now in the machine, run
ansible-playbook -u root -i localhost, -c local --tags sssd_enable_pam_services playbook.yml

If you build the content before this PR, it should crash. It should finish without errors when this PR is added.

older Ansible versions might terminate prematurely if there are no config files found in /etc/sssd/conf.d directory
@vojtapolasek vojtapolasek added bugfix Fixes to reported bugs. Ansible Ansible remediation update. RHEL7 Red Hat Enterprise Linux 7 product related. labels May 9, 2024
@vojtapolasek vojtapolasek added this to the 0.1.73 milestone May 9, 2024
Copy link

github-actions bot commented May 9, 2024

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented May 9, 2024

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_sssd_enable_pam_services' differs.
--- xccdf_org.ssgproject.content_rule_sssd_enable_pam_services
+++ xccdf_org.ssgproject.content_rule_sssd_enable_pam_services
@@ -39,7 +39,9 @@
     replace: \1,pam
   with_items: '{{ sssd_conf_d_files.files | map(attribute=''path'') }}'
   register: modify_lines_sssd_conf_d_files
-  when: '"sssd-common" in ansible_facts.packages'
+  when:
+  - '"sssd-common" in ansible_facts.packages'
+  - sssd_conf_d_files.matched is defined and sssd_conf_d_files.matched >= 1
   tags:
   - CCE-82446-6
   - NIST-800-53-CM-6(a)

Copy link

github-actions bot commented May 9, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11979
This image was built from commit: 6f93bc0

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11979

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11979 make deploy-local

@jan-cerny jan-cerny self-assigned this May 9, 2024
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have confirmed on RHEL 7.9 that this patch fixes the problem.

The fail of Automatus on SLE15 is expected because this rule isn't part of the SLE15 content.

@jan-cerny
Copy link
Collaborator

@vojtapolasek please send a link to the master variant of this patch

@jan-cerny jan-cerny merged commit 354a95c into ComplianceAsCode:stabilization-v0.1.73 May 9, 2024
102 of 103 checks passed
@vojtapolasek
Copy link
Collaborator Author

The PR against master is here: #11982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. bugfix Fixes to reported bugs. RHEL7 Red Hat Enterprise Linux 7 product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants