inspec/docs/resources/apt.md.erb

82 lines
1.7 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the apt Resource
platform: linux
2016-09-22 12:43:57 +00:00
---
# 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.
<br>
## Availability
### Installation
This resource is distributed along with InSpec itself. You can use it automatically.
### Version
This resource first became available in v1.0.0 of InSpec.
## Syntax
2016-09-22 12:43:57 +00:00
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
<br>
2016-09-22 12:43:57 +00:00
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test if apt repository exists and is enabled
2016-09-22 12:43:57 +00:00
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
2016-09-22 12:43:57 +00:00
describe apt('ppa:nginx/stable') do
it { should exist }
it { should be_enabled }
end
### Verify that a repository is not present
2016-09-22 12:43:57 +00:00
describe apt('ubuntu-wine/ppa') do
it { should_not exist }
it { should_not be_enabled }
end
<br>
## Matchers
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
### be_enabled
The `be_enabled` matcher tests if a repository is enabled on the system:
it { should be_enabled }
### exist
The `exist` matcher tests if a repository exists on the system:
it { should exist }