mirror of
https://github.com/inspec/inspec
synced 2024-11-24 05:33:17 +00:00
b0bcc35fda
Signed-off-by: kagarmoe <kgarmoe@chef.io>
67 lines
1.5 KiB
Text
67 lines
1.5 KiB
Text
---
|
|
title: About the packages Resource
|
|
platform: linux
|
|
---
|
|
|
|
# packages
|
|
|
|
Use the `packages` InSpec audit resource to test the properties of multiple packages on the system.
|
|
|
|
<br>
|
|
|
|
## 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
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Verify that no `xserver` packages are installed
|
|
|
|
describe package(/xserver/) do
|
|
its('statuses') { should_not cmp 'installed' }
|
|
end
|
|
|
|
### Verify all `openssl` packages match a certain version
|
|
|
|
describe package(/openssl/) do
|
|
its('versions') { should cmp '1.0.1e-42.el7' }
|
|
end
|
|
|
|
### Verify that both the `i686` and `x86_64` versions of `libgcc` are installed
|
|
|
|
describe package(/libgcc/) do
|
|
its('architectures') { should include 'x86_64' }
|
|
its('architectures') { should include 'i686' }
|
|
end
|
|
|
|
<br>
|
|
|
|
## Matchers
|
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
|
|
### 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' }
|