2017-06-07 12:10:29 +00:00
|
|
|
---
|
|
|
|
title: About the virtualization Resource
|
2018-02-16 00:28:15 +00:00
|
|
|
platform: linux
|
2017-06-07 12:10:29 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# virtualization
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
Use the `virtualization` Chef InSpec audit resource to test the virtualization platform on which the system is running.
|
2017-06-07 12:10:29 +00:00
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
|
|
|
|
2018-08-09 12:34:49 +00:00
|
|
|
## Availability
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
This resource is distributed along with Chef InSpec itself. You can use it automatically.
|
2018-08-09 12:34:49 +00:00
|
|
|
|
|
|
|
### Version
|
|
|
|
|
|
|
|
This resource first became available in v1.28.0 of InSpec.
|
|
|
|
|
2017-06-07 12:10:29 +00:00
|
|
|
## 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
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
2017-06-07 12:10:29 +00:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
The following examples show how to use this Chef InSpec audit resource.
|
2017-06-07 12:10:29 +00:00
|
|
|
|
|
|
|
### 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
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
|
|
|
|
|
|
|
## Matchers
|
|
|
|
|
2018-02-16 03:07:18 +00:00
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|