inspec/docs/resources/pip.md.erb

75 lines
1.4 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the pip Resource
---
# pip
Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.
## Syntax
2016-09-22 12:43:57 +00:00
A `pip` resource block declares a package and (optionally) a package version:
describe pip('package_name') do
2016-09-22 12:43:57 +00:00
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
2016-09-22 12:43:57 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
### be_installed
2016-09-22 12:43:57 +00:00
The `be_installed` matcher tests if the named package is installed on the system:
it { should be_installed }
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
### version
2016-09-22 12:43:57 +00:00
The `version` matcher tests if the named package version is on the system:
its('version') { should eq '1.2.3' }
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test if Jinja2 is installed on the system
2016-09-22 12:43:57 +00:00
describe pip('Jinja2') do
it { should be_installed }
end
### Test if Jinja2 2.8 is installed on the system
2016-09-22 12:43:57 +00:00
describe pip('Jinja2') do
it { should be_installed }
its('version') { should eq '2.8' }
end