仅使用 specifig 控件:
在命令帮助中找到它说:
[--controls=one two three]
# A list of control names to run, or a list of /regexes/ to match a gainst control names. Ignore all other tests.
(我现在也在文档中找到它:https ://docs.chef.io/inspec/cli/#options-3 )
以下将仅执行指定配置文件中以“ssh”开头的控件:
inspec exec /profilepath/profilename --controls "/ssh-.*/"
覆盖控件
要覆盖特定控件,可以在配置文件的“控件”目录中覆盖它们,该目录可以“应用在基线之上”,其中包含,请参阅https://blog.chef.io/understanding- inspec-profile-inheritance,例如:
include_controls 'linux-baseline' do
somevariable = attribute('somevariable', value: false, description: 'do something')
control 'package-08' do
impact 1.0
title 'Install pkg'
desc 'install some packaged'
only_if { somevariable }
audit_pkg = 'packagename'
describe package(mypkg) do
it { should be_installed }
end
end
include "linux-patch-baseline"
# nothing to replace here