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

Fix kernel_module for centos/redhat #1513

Merged
merged 3 commits into from
Mar 2, 2017
Merged

Fix kernel_module for centos/redhat #1513

merged 3 commits into from
Mar 2, 2017

Conversation

aladmit
Copy link

@aladmit aladmit commented Feb 24, 2017

Hi! I fixed kernel_module resource for centos/redhat.

issue: #1507

Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Thank you @postgred for bringing up the change! Have you tested this on RedHat 6 and RedHat 7?

lsmod_cmd = 'lsmod'
# special care for CentOS 5 and sudo
lsmod_cmd = '/sbin/lsmod' if inspec.os[:name] == 'centos' && inspec.os[:release].to_i == 5
if inspec.os[:family] == 'redhat'
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to avoid using inspec.os[:family] . A better approach is to use inspec.os.redhat?

@@ -37,7 +38,7 @@ def loaded?
end

def version
if inspec.os[:name] == 'centos' && inspec.os[:release].to_i == 5
if inspec.os[:family] == 'redhat'
Copy link

@Fodoj Fodoj Feb 24, 2017

Choose a reason for hiding this comment

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

This would resolve to true for any version of any rhel-based distro, so high chance it will either break for some of existing versions or it will break for some of future versions. I would suggest to keep this check, but only for distro versions in trouble.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Fodoj thank you for highlighting this issue. I assume this applies to RedHat 5 as well, therefore we may need to ask for

if inspec.os.redhat? && inspec.os[:release].to_i == 5

Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
@aladmit
Copy link
Author

aladmit commented Feb 24, 2017

@chris-rock Yeah, I have tested this on CentOS5-7 and RedHat6-7

@@ -37,7 +38,7 @@ def loaded?
end

def version
if inspec.os[:name] == 'centos' && inspec.os[:release].to_i == 5
if inspec.os.family == 'redhat'
Copy link
Contributor

Choose a reason for hiding this comment

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

@postgred it is better to use inspec.os.redhat?. we try to avoid inspec.os.family. This is inherited from Serverspec. We are going to prefer the name or the helper method.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, If you don't want use os.family, we can use 'os.redhat? || os.name == 'fedora'` (I have found the problem on fedora too).

Copy link
Contributor

Choose a reason for hiding this comment

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

@postgred Yes, that would be appreciated.

Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
@aladmit
Copy link
Author

aladmit commented Feb 26, 2017

@chris-rock I have removed os.family. Should I do something else?

Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Thank you @postgred

@chris-rock
Copy link
Contributor

@Fodoj do you see any issues left?

@chris-rock chris-rock requested a review from adamleff March 1, 2017 18:23
@Fodoj
Copy link

Fodoj commented Mar 1, 2017

lgtm

@chris-rock chris-rock merged commit be529dc into inspec:master Mar 2, 2017
@chris-rock
Copy link
Contributor

Thank you @postgred

@adamleff
Copy link
Contributor

adamleff commented Mar 2, 2017

Looks great. Thanks @postgred!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants