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

kernel_module_disable template - regexp matches multiple lines #10351

Merged
merged 1 commit into from
Mar 23, 2023

Conversation

nnerdmann
Copy link
Contributor

Regular expression matches both lines in the {{KERNMODULE}}.conf file and this causes duplicate lines in Oracle Linux and RHEL every time the ansible script is executed. Regular expression was changed to also search for the keyword "install"

Description:

The regular expression for the line "install {{KERNMODULE}} /bin/true" is only "{{KERNMODULE}}"
This causes duplicate lines in the modprobe.d/*.conf files

Rationale:

In case of Oracle Linux or RHEL, there are 2 lines in the {{KERNMODULE}}.conf file and the regular expression will match always the last match (according to ansible documentation).

For example for udf:

# cat /etc/modprobe.d/udf.conf
install udf /bin/true
blacklist udf

Old regexp would be udf and would match blacklist udf
New regexp would be install\s+udf and would match install udf /bin/true

With old regexp the file would look like this:

# cat /etc/modprobe.d/udf.conf
install udf /bin/true
install udf /bin/true

With new regexp the file would look like this:

# cat /etc/modprobe.d/udf.conf
install udf /bin/true
blacklist udf

Review Hints:

The second part of the ansible block takes care of the blacklist line, so with the old regexp the result would be actually:

# cat /etc/modprobe.d/udf.conf
install udf /bin/true
install udf /bin/true
blacklist udf

Regular expression matches both lines in the {{KERNMODULE}}.conf file and this causes duplicate lines in Oracle Linux and RHEL every time the ansible script is executed. Regular expression was changed to also search for the keyword "install"
@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Mar 22, 2023
@openshift-ci
Copy link

openshift-ci bot commented Mar 22, 2023

Hi @nnerdmann. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@nnerdmann nnerdmann changed the title Regexp matches multiple lines kernel_module_disable template - regexp matches multiple lines Mar 22, 2023
@github-actions
Copy link

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

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@Mab879 Mab879 added the Ansible Ansible remediation update. label Mar 22, 2023
@Mab879
Copy link
Member

Mab879 commented Mar 22, 2023

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Mar 22, 2023
@codeclimate
Copy link

codeclimate bot commented Mar 22, 2023

Code Climate has analyzed commit 201ba41 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 51.8% (0.0% change).

View more on Code Climate.

@vojtapolasek vojtapolasek self-assigned this Mar 23, 2023
@vojtapolasek vojtapolasek added this to the 0.1.67 milestone Mar 23, 2023
Copy link
Collaborator

@vojtapolasek vojtapolasek left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for th excellent PR description.

@vojtapolasek vojtapolasek merged commit 287475d into ComplianceAsCode:master Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants