inspec/docs/resources/yum.md.erb

104 lines
2.3 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the yum Resource
---
# yum
Use the `yum` InSpec audit resource to test packages in the Yum repository.
## 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'`)
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
### be_enabled
2016-09-22 12:43:57 +00:00
The `be_enabled` matcher tests if the package repository is a valid package source:
it { should be_enabled }
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
### exist
2016-09-22 12:43:57 +00:00
The `exist` matcher tests if the package repository exists:
it { should exist }
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
### 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
### 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' }
### shortname
2016-09-22 12:43:57 +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 idenfier is typically "directory-server":
describe yum.repo('Directory Server') do
its('shortname') { should eq 'directory-server' }
end
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test if the yum repo exists
2016-09-22 12:43:57 +00:00
describe yum do
its('repos') { should exist }
end
### Test if the 'base/7/x86_64' repo exists and is enabled
2016-09-22 12:43:57 +00:00
describe yum do
its('repos') { should include 'base/7/x86_64' }
its('epel') { should exist }
its('epel') { should be_enabled }
end
### Test if a specific yum repo exists
2016-09-22 12:43:57 +00:00
describe yum.repo('epel') do
it { should exist }
it { should be_enabled }
end