2016-09-22 14:43:57 +02:00
---
title: About the apt Resource
2018-02-15 18:28:15 -06:00
platform: linux
2016-09-22 14:43:57 +02:00
---
# apt
2019-04-26 14:24:29 -04:00
Use the `apt` Chef InSpec audit resource to verify Apt repositories on the Debian and Ubuntu platforms, and also PPA repositories on the Ubuntu platform.
2016-09-22 14:43:57 +02:00
2017-10-03 14:35:10 -07:00
<br>
2018-08-09 08:34:49 -04:00
## Availability
### Installation
2019-04-26 14:24:29 -04:00
This resource is distributed along with Chef InSpec itself. You can use it automatically.
2018-08-09 08:34:49 -04:00
### Version
This resource first became available in v1.0.0 of InSpec.
2016-09-27 12:03:23 -07:00
## Syntax
2016-09-22 14:43:57 +02: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
2017-10-03 14:35:10 -07:00
<br>
2016-09-22 14:43:57 +02:00
2016-09-27 12:03:23 -07:00
## Examples
2016-09-22 14:43:57 +02:00
2019-04-26 14:24:29 -04:00
The following examples show how to use this Chef InSpec audit resource.
2016-09-22 14:43:57 +02:00
2016-09-27 12:03:23 -07:00
### Test if apt repository exists and is enabled
2016-09-22 14:43:57 +02:00
describe apt('http://ppa.launchpad.net/juju/stable/ubuntu') do
it { should exist }
it { should be_enabled }
end
2016-09-27 12:03:23 -07:00
### Verify that a PPA repository exists and is enabled
2016-09-22 14:43:57 +02:00
describe apt('ppa:nginx/stable') do
it { should exist }
it { should be_enabled }
end
2016-09-27 12:03:23 -07:00
### Verify that a repository is not present
2016-09-22 14:43:57 +02:00
describe apt('ubuntu-wine/ppa') do
it { should_not exist }
it { should_not be_enabled }
end
2017-10-03 14:35:10 -07:00
<br>
## Matchers
2018-02-15 19:07:18 -08:00
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2017-10-03 14:35:10 -07:00
### be_enabled
2019-04-03 08:47:41 +02:00
The `be_enabled` matcher tests if a repository is enabled on the system:
2017-10-03 14:35:10 -07:00
it { should be_enabled }
### exist
2019-04-03 08:47:41 +02:00
The `exist` matcher tests if a repository exists on the system:
2017-10-03 14:35:10 -07:00
it { should exist }