2016-09-22 12:43:57 +00:00
---
title: About the yum Resource
2018-02-16 00:28:15 +00:00
platform: linux
2016-09-22 12:43:57 +00:00
---
# yum
2019-04-26 18:24:29 +00:00
Use the `yum` Chef InSpec audit resource to test packages in the Yum repository.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +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.0.0 of InSpec.
2016-09-27 19:03:23 +00:00
## Syntax
2016-09-22 12:43:57 +00:00
A `yum` resource block declares a package repo, tests if the package repository is present, and if it that package repository is a valid package source (i.e. "is enabled"):
describe yum.repo('name') do
it { should exist }
it { should be_enabled }
end
where
* `repo('name')` is the (optional) name of a package repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`)
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Examples
2016-09-22 12:43:57 +00:00
2019-04-26 18:24:29 +00:00
The following examples show how to use this Chef InSpec audit resource.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test if the yum repo exists
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe yum do
its('repos') { should exist }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test if the 'base/7/x86_64' repo exists and is enabled
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe yum do
its('repos') { should include 'base/7/x86_64' }
its('epel') { should exist }
its('epel') { should be_enabled }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test if a specific yum repo exists
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe yum.repo('epel') do
it { should exist }
it { should be_enabled }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test a particular repository configuration, such as its Base URL
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe yum.repo('mycompany-artifacts') do
it { should exist }
it { should be_enabled }
its('baseurl') { should include 'mycompany.biz' }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
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/).
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### be_enabled
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
The `be_enabled` matcher tests if the package repository is a valid package source:
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
it { should be_enabled }
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### exist
The `exist` matcher tests if the package repository exists:
it { should exist }
2016-09-22 12:43:57 +00:00
2016-09-27 19:03:23 +00:00
### repo('name')
2016-09-22 12:43:57 +00:00
The `repo('name')` matcher names a specific package repository:
describe yum.repo('epel') do
...
end
2016-09-27 19:03:23 +00:00
### repos
2016-09-22 12:43:57 +00:00
The `repos` matcher tests if a named repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`), is included in the Yum repo:
its('repos') { should include 'some_repo' }
2016-09-27 19:03:23 +00:00
### shortname
2016-09-22 12:43:57 +00:00
2018-03-20 12:43:30 +00:00
The `shortname` matcher names a specific package repository's group identifier. For example, if a repository's group name is "Directory Server", the corresponding group identifier is typically "directory-server":
2016-09-22 12:43:57 +00:00
describe yum.repo('Directory Server') do
its('shortname') { should eq 'directory-server' }
end