mirror of
https://github.com/inspec/inspec
synced 2024-12-18 17:14:33 +00:00
9283f19b6e
Signed-off-by: David Wrede <dwrede@chef.io>
84 lines
1.7 KiB
Text
84 lines
1.7 KiB
Text
---
|
|
title: About the apt Resource
|
|
---
|
|
|
|
# apt
|
|
|
|
Use the `apt` InSpec audit resource to verify Apt repositories on the Debian and Ubuntu platforms, and also PPA repositories on the Ubuntu platform.
|
|
|
|
## Syntax
|
|
|
|
An `apt` resource block tests the contents of Apt and PPA repositories:
|
|
|
|
describe apt('path') do
|
|
it { should exist }
|
|
it { should be_enabled }
|
|
end
|
|
|
|
where
|
|
|
|
* `apt('path')` must specify an Apt or PPA repository
|
|
* `('path')` may be an `http://` address, a `ppa:` address, or a short `repo-name/ppa` address
|
|
* `exist` and `be_enabled` are a valid matchers for this resource
|
|
|
|
|
|
## Matchers
|
|
|
|
This InSpec audit resource has the following matchers:
|
|
|
|
### be
|
|
|
|
<%= partial "/shared/matcher_be" %>
|
|
|
|
### be_enabled
|
|
|
|
The `be_enabled` matcher tests if a package exists in the repository:
|
|
|
|
it { should be_enabled }
|
|
|
|
### cmp
|
|
|
|
<%= partial "/shared/matcher_cmp" %>
|
|
|
|
### eq
|
|
|
|
<%= partial "/shared/matcher_eq" %>
|
|
|
|
### exist
|
|
|
|
The `exist` matcher tests if a package exists on the system:
|
|
|
|
it { should exist }
|
|
|
|
### include
|
|
|
|
<%= partial "/shared/matcher_include" %>
|
|
|
|
### match
|
|
|
|
<%= partial "/shared/matcher_match" %>
|
|
|
|
## Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Test if apt repository exists and is enabled
|
|
|
|
describe apt('http://ppa.launchpad.net/juju/stable/ubuntu') do
|
|
it { should exist }
|
|
it { should be_enabled }
|
|
end
|
|
|
|
### Verify that a PPA repository exists and is enabled
|
|
|
|
describe apt('ppa:nginx/stable') do
|
|
it { should exist }
|
|
it { should be_enabled }
|
|
end
|
|
|
|
### Verify that a repository is not present
|
|
|
|
describe apt('ubuntu-wine/ppa') do
|
|
it { should_not exist }
|
|
it { should_not be_enabled }
|
|
end
|