mirror of
https://github.com/inspec/inspec
synced 2025-01-20 09:04:35 +00:00
c5b12cbe4a
Signed-off-by: Thomas Heinen <theinen@tecracer.de>
107 lines
2.5 KiB
Text
107 lines
2.5 KiB
Text
---
|
|
title: About the virtualization Resource
|
|
platform: linux
|
|
---
|
|
|
|
# virtualization
|
|
|
|
Use the `virtualization` Chef InSpec audit resource to test the virtualization platform on which the system is running.
|
|
|
|
<br>
|
|
|
|
## Availability
|
|
|
|
### Installation
|
|
|
|
This resource is distributed along with Chef InSpec itself. You can use it automatically.
|
|
|
|
### Version
|
|
|
|
This resource first became available in v1.28.0 of InSpec.
|
|
|
|
## Syntax
|
|
|
|
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 tested
|
|
|
|
<br>
|
|
|
|
## Examples
|
|
|
|
The following examples show how to use this Chef InSpec audit resource.
|
|
|
|
### Test for Docker
|
|
|
|
describe virtualization do
|
|
its('system') { should eq 'docker' }
|
|
end
|
|
|
|
### Test for VirtualBox
|
|
|
|
describe virtualization do
|
|
its('system') { should eq 'vbox' }
|
|
its('role') { should eq 'guest' }
|
|
end
|
|
|
|
### Detect the virtualization platform
|
|
|
|
if virtualization.system == 'vbox'
|
|
describe package('name') do
|
|
it { should be_installed }
|
|
end
|
|
end
|
|
|
|
<br>
|
|
|
|
## Matchers
|
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
|
|
### virtualization.virtual_system? Helper
|
|
|
|
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.
|
|
|
|
### virtualization.physical_system? Helper
|
|
|
|
If no virtualization platform is detected, this will return `true`. For unsupported virtualization platforms this can result in false posititves.
|
|
|
|
### virtualization.system names
|
|
|
|
The resource supports the following virtualization platforms:
|
|
|
|
On Linux machines:
|
|
* `docker` (`guest` role only)
|
|
* `hyper-v` (`guest` role only)
|
|
* `kvm`
|
|
* `linux vserver`
|
|
* `lxc` / `lxd`
|
|
* `openstack` (`host` role only)
|
|
* `openvz`
|
|
* `parallels` (`guest` role only)
|
|
* `virtualbox`
|
|
* `vmware` (`guest` role only)
|
|
* `xen`
|
|
|
|
On Windows machines (`guest` role only)
|
|
* `hyper-v`
|
|
* `kvm`
|
|
* `vmware`
|
|
* `virtualbox`
|
|
* `xen`
|
|
|
|
### virtualization.role
|
|
|
|
Can be either
|
|
* `guest`
|
|
* `host`
|
|
|
|
Please see the documentation on `virtualization.system` to check supported roles per platform.
|