Use the yum Chef InSpec audit resource to test packages in the Yum repository.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
This resource first became available in v1.0.0 of InSpec.
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')The following examples show how to use this Chef InSpec audit resource.
describe yum do
its('repos') { should exist }
end
describe yum do
its('repos') { should include 'base/7/x86_64' }
its('epel') { should exist }
its('epel') { should be_enabled }
end
describe yum.repo('epel') do
it { should exist }
it { should be_enabled }
end
describe yum.repo('mycompany-artifacts') do
it { should exist }
it { should be_enabled }
its('baseurl') { should include 'mycompany.biz' }
end
For a full list of available matchers, please visit our matchers page.
The be_enabled matcher tests if the package repository is a valid package source:
it { should be_enabled }
The exist matcher tests if the package repository exists:
it { should exist }
The repo('name') matcher names a specific package repository:
describe yum.repo('epel') do
...
end
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' }
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”:
describe yum.repo('Directory Server') do
its('shortname') { should eq 'directory-server' }
end
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/yum/