Use the virtualization Chef InSpec audit resource to test the virtualization platform on which the system is running.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
This resource first became available in v1.28.0 of InSpec.
An virtualization resource block declares the virtualization platform that should be tested:
describe virtualization do
its('system') { should MATCHER 'value' }
end
where
('system') is the name of the system information of the virtualization platform (e.g. docker, lxc, vbox, kvm, etc)MATCHER is a valid matcher for this resource'value' is the value to be testedThe following examples show how to use this Chef InSpec audit resource.
describe virtualization do
its('system') { should eq 'docker' }
end
describe virtualization do
its('system') { should eq 'vbox' }
its('role') { should eq 'guest' }
end
if virtualization.system == 'vbox'
describe package('name') do
it { should be_installed }
end
end
For a full list of available matchers, please visit our matchers page.
This helper returns, if any of the supported virtualization platforms was detected and the machine under test is a guest. You can use this in a only_if { virtual_system? } clause to execute test only on virtualized systems.
If no virtualization platform is detected, this will return true. For unsupported virtualization platforms this can result in false posititves.
The resource supports the following virtualization platforms:
On Linux machines:
docker (guest role only)hyper-v (guest role only)kvmlinux vserverlxc / lxd
openstack (host role only)openvzparallels (guest role only)virtualboxvmware (guest role only)xenOn Windows machines (guest role only)
hyper-vkvmvmwarevirtualboxxenCan be either
guesthostPlease see the documentation on virtualization.system to check supported roles per platform.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/virtualization/