Skip to main content

kernel_parameters resource

Use the kernel_parameters Chef InSpec audit resource to test multiple kernel parameters on Linux platforms. These parameters are located under /proc/cmdline.

Availability

Install

This resource is distributed with Chef InSpec and is automatically available for use.

Syntax

A kernel_parameters resource block uses where to filter entries from the systems kernel parameters. If where is omitted, all entries are selected.

describe kernel_parameters do
  its('parameters') { should include "PARAMETER_NAME" }
  its('values') { should include 1 }
end

describe kernel_parameters.where(parameter: "PARAMETER_NAME") do
  its('values') { should eq [1] }
end

Properties

parameters

The kernel parameter to test.

values

The value of a kernel parameter.

Examples

The following examples show how to use this Chef InSpec audit resource.

Test the global forwarding setting using a where query on the kernel parameters

describe kernel_parameters.where(parameter: "net.ipv4.conf.all.forwarding") do
  its('values') { should eq [1] }
end

Match a parameter using a regular expression

describe kernel_parameters.where(parameter: /^net./ ) do
  its('parameters') { should include 'net.ipv4.conf.all.forwarding' }
end

Matchers

For a full list of available matchers, see our Universal Matchers page.
Edit this page on GitHub

Thank you for your feedback!

×











Search Results