mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
a9726910ff
* Fixes the npm package example to state 'npm' vs 'gem' * Fixes powershell resource to specify the resource instead of 'script' * Updates the example to rename variable 'script' While ruby would allow the local variable and the presence of the InSpec method at the same time I think that it is bad form. Other resource examples also use 'script'. * Changes pip to show generic example Other package like resources show a generic example in the default. Signed-off-by: Franklin Webber <franklin@chef.io>
74 lines
1.4 KiB
Text
74 lines
1.4 KiB
Text
---
|
|
title: About the pip Resource
|
|
---
|
|
|
|
# pip
|
|
|
|
Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.
|
|
|
|
## Syntax
|
|
|
|
A `pip` resource block declares a package and (optionally) a package version:
|
|
|
|
describe pip('package_name') do
|
|
it { should be_installed }
|
|
end
|
|
|
|
where
|
|
|
|
* `'package_name'` is the name of the package, such as `'Jinja2'`
|
|
* `be_installed` tests to see if the package described above is installed
|
|
|
|
|
|
## Matchers
|
|
|
|
This InSpec audit resource has the following matchers:
|
|
|
|
### be
|
|
|
|
<%= partial "/shared/matcher_be" %>
|
|
|
|
### be_installed
|
|
|
|
The `be_installed` matcher tests if the named package is installed on the system:
|
|
|
|
it { should be_installed }
|
|
|
|
### cmp
|
|
|
|
<%= partial "/shared/matcher_cmp" %>
|
|
|
|
### eq
|
|
|
|
<%= partial "/shared/matcher_eq" %>
|
|
|
|
### include
|
|
|
|
<%= partial "/shared/matcher_include" %>
|
|
|
|
### match
|
|
|
|
<%= partial "/shared/matcher_match" %>
|
|
|
|
### version
|
|
|
|
The `version` matcher tests if the named package version is on the system:
|
|
|
|
its('version') { should eq '1.2.3' }
|
|
|
|
## Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Test if Jinja2 is installed on the system
|
|
|
|
describe pip('Jinja2') do
|
|
it { should be_installed }
|
|
end
|
|
|
|
### Test if Jinja2 2.8 is installed on the system
|
|
|
|
describe pip('Jinja2') do
|
|
it { should be_installed }
|
|
its('version') { should eq '2.8' }
|
|
end
|