2018-01-26 07:57:34 +00:00
|
|
|
---
|
|
|
|
title: About the packages Resource
|
2018-02-16 00:28:15 +00:00
|
|
|
platform: linux
|
2018-01-26 07:57:34 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# packages
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
Use the `packages` Chef InSpec audit resource to test the properties of multiple packages on the system.
|
2018-01-26 07:57:34 +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.51.15 of InSpec.
|
|
|
|
|
2018-01-26 07:57:34 +00:00
|
|
|
## Syntax
|
|
|
|
|
|
|
|
A `packages` resource block declares a regular expression search to select packages
|
|
|
|
|
|
|
|
describe packages(/name/) do
|
|
|
|
its('statuses') { should cmp 'installed' }
|
|
|
|
end
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
The following examples show how to use this Chef InSpec audit resource.
|
2018-01-26 07:57:34 +00:00
|
|
|
|
|
|
|
### Verify that no `xserver` packages are installed
|
|
|
|
|
2018-10-08 13:35:30 +00:00
|
|
|
describe packages(/xserver/) do
|
2018-01-26 07:57:34 +00:00
|
|
|
its('statuses') { should_not cmp 'installed' }
|
|
|
|
end
|
|
|
|
|
|
|
|
### Verify all `openssl` packages match a certain version
|
|
|
|
|
2018-10-08 13:35:30 +00:00
|
|
|
describe packages(/openssl/) do
|
2018-01-26 07:57:34 +00:00
|
|
|
its('versions') { should cmp '1.0.1e-42.el7' }
|
|
|
|
end
|
|
|
|
|
|
|
|
### Verify that both the `i686` and `x86_64` versions of `libgcc` are installed
|
|
|
|
|
2018-10-08 13:35:30 +00:00
|
|
|
describe packages(/libgcc/) do
|
2018-01-26 07:57:34 +00:00
|
|
|
its('architectures') { should include 'x86_64' }
|
|
|
|
its('architectures') { should include 'i686' }
|
|
|
|
end
|
|
|
|
|
|
|
|
<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/).
|
2018-01-26 07:57:34 +00:00
|
|
|
|
|
|
|
### statuses
|
|
|
|
|
|
|
|
The `statuses` matcher tests if packages are installed on the system
|
|
|
|
|
|
|
|
its('statuses') { should cmp 'installed' }
|
|
|
|
|
|
|
|
### versions
|
|
|
|
|
|
|
|
The `versions` matcher tests the versions of the packages installed on the system
|
|
|
|
|
|
|
|
its('versions') { should cmp '3.4.0.2-4.el7' }
|
|
|
|
|
|
|
|
### architectures
|
|
|
|
|
|
|
|
The `architectures` matcher tests the architecture of packages installed on the system
|
|
|
|
|
|
|
|
its('architectures') { should include 'i686' }
|