Skip to content

Conversation

@jan-cerny
Copy link
Collaborator

Description:

This PR will make Ansible remediations in the following rules idempotent:

  • postfix_client_configure_mail_alias
  • postfix_client_configure_mail_alias_postmaster

Specifically, the Ansible Task that executes the newaliases shell command will now be run only if the configuration file has been changed by the Ansible Task above.

As a part of the solution, we will add new optional parameter register to the ansible_set_config_file Jinja macro. It will allow callers to register a variable holding result of the lineinfile Ansible Task and use this registered variable in other Ansible Tasks to check if lineinfile module changed the target file or if the target file is already configured OK.

Rationale:

Resolves: https://issues.redhat.com/browse/OPENSCAP-6245

Review Hints:

  • ./build_product --playbook-per-rule rhel9
  • manually replace hosts by hosts: all in build/rhel9/playbooks/stig/postfix_client_configure_mail_alias.yml and build/rhel9/playbooks/stig/postfix_client_configure_mail_alias_postmaster.yml
  • run ansible-playbook -u root -i YOUR_IP, build/rhel9/playbooks/stig/postfix_client_configure_mail_alias.yml at least twice and compare the output of the first run with the second run and so on, verify that the second and next runs don't change anything and that the output contains only "ok" or "skipping"
  • dtto with the second playbook
  • apart from that, run automatus Tss with --remediate-using ansible

The new optional parameter `register` of `ansible_set_config_file` will
allow callers to register a variable holding result of
the lineinfile task and use this registered variable in other tasks
to check if lineinfile module changed the target file or if the
target file is alrady configured OK.
@jan-cerny jan-cerny added this to the 0.1.79 milestone Sep 25, 2025
@jan-cerny jan-cerny added the Ansible Ansible remediation update. label Sep 25, 2025
@openshift-ci
Copy link

openshift-ci bot commented Sep 25, 2025

@jan-cerny: The following tests 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/e2e-aws-openshift-node-compliance c70584d link true /test e2e-aws-openshift-node-compliance
ci/prow/e2e-aws-openshift-platform-compliance c70584d link true /test e2e-aws-openshift-platform-compliance

Full PR test history. Your PR dashboard.

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.

@ggbecker ggbecker self-assigned this Sep 29, 2025
Copy link
Member

@ggbecker ggbecker 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 run ansible playbooks tests and automatus with the same set of rules reported by CTF in the Automatus gating tests using a RHEL9 system and everything worked as expected.

@ggbecker ggbecker merged commit b3ee0d9 into ComplianceAsCode:master Sep 29, 2025
133 of 138 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.

2 participants