2016-09-22 12:43:57 +00:00
---
title: About the kernel_module Resource
---
# kernel_module
Use the `kernel_module` InSpec audit resource to test kernel modules on Linux platforms. These parameters are located under `/lib/modules`. Any submodule may be tested using this resource.
2016-09-27 19:03:23 +00:00
## Syntax
2016-09-22 12:43:57 +00:00
A `kernel_module` resource block declares a module name, and then tests if that module is a loadable kernel module:
describe kernel_module('module_name') do
it { should be_loaded }
end
where
* `'module_name'` must specify a kernel module, such as `'bridge'`
* `{ should be_loaded }` tests if the module is a loadable kernel module
2016-09-27 19:03:23 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
2016-09-27 19:03:23 +00:00
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
2016-09-27 19:03:23 +00:00
### be_loaded
2016-09-22 12:43:57 +00:00
The `be_loaded` matcher tests if the module is a loadable kernel module:
it { should be_loaded }
2016-09-27 19:03:23 +00:00
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
2016-09-27 19:03:23 +00:00
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
2016-09-27 19:03:23 +00:00
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
2016-09-27 19:03:23 +00:00
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
2017-01-25 20:47:39 +00:00
### version
The `version` matcher tests if the named module version is on the system:
its(:version) { should eq '3.2.2' }
2016-09-27 19:03:23 +00:00
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
2016-09-27 19:03:23 +00:00
### Test if a module is loaded
2016-09-22 12:43:57 +00:00
describe kernel_module('bridge') do
it { should be_loaded }
2017-01-25 20:47:39 +00:00
its(:version) { should cmp >= '2.2.2' }
2016-09-22 12:43:57 +00:00
end