Commit f9e182ee authored by Sean OMeara's avatar Sean OMeara

Adding testing bits to Gemfile, cleaning up some style issues

parent 6a121e5a
source 'https://rubygems.org'
gem 'strainer'
gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 3.0'
gem 'foodcritic', '~> 3.0'
gem 'rubocop', '~> 0.14'
group :integration do
gem 'test-kitchen', '~> 1.0.0.beta.4'
gem 'kitchen-vagrant', '~> 0.11'
end
# Encoding: utf-8
#
# Cookbook Name:: yum
# Attributes:: default
......@@ -19,8 +20,8 @@
#
# Example: override.yum.exclude = "kernel* compat-glibc*"
default['yum']['exclude'] = Array.new
default['yum']['installonlypkgs'] = Array.new
default['yum']['exclude'] = []
default['yum']['installonlypkgs'] = []
default['yum']['ius_release'] = '1.0-11'
default['yum']['repoforge_release'] = '0.5.2-2'
default['yum']['proxy'] = ''
......
# Encoding: utf-8
#
# Cookbook Name:: yum
# Attributes:: elrepo
......@@ -18,7 +19,7 @@
#
default['yum']['elrepo']['url'] = "http://elrepo.org/mirrors-elrepo.el#{node['platform_version'].to_i}"
default['yum']['elrepo']['key'] = "RPM-GPG-KEY-elrepo.org"
default['yum']['elrepo']['key'] = 'RPM-GPG-KEY-elrepo.org'
default['yum']['elrepo']['key_url'] = "http://elrepo.org/#{node['yum']['elrepo']['key']}"
default['yum']['elrepo']['includepkgs'] = nil
default['yum']['elrepo']['exclude'] = nil
# Encoding: utf-8
#
# Cookbook Name:: yum
# Attributes:: epel
......@@ -19,18 +20,18 @@
#
case node['platform']
when "amazon"
default['yum']['epel']['url'] = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch"
default['yum']['epel']['baseurl'] = ""
default['yum']['epel']['key'] = "RPM-GPG-KEY-EPEL-6"
when 'amazon'
default['yum']['epel']['url'] = 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch'
default['yum']['epel']['baseurl'] = ''
default['yum']['epel']['key'] = 'RPM-GPG-KEY-EPEL-6'
else
default['yum']['epel']['url'] = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-#{node['platform_version'].to_i}&arch=$basearch"
default['yum']['epel']['baseurl'] = ""
default['yum']['epel']['baseurl'] = ''
if node['platform_version'].to_i >= 6
default['yum']['epel']['key'] = "RPM-GPG-KEY-EPEL-6"
default['yum']['epel']['key'] = 'RPM-GPG-KEY-EPEL-6'
else
default['yum']['epel']['key'] = "RPM-GPG-KEY-EPEL"
default['yum']['epel']['key'] = 'RPM-GPG-KEY-EPEL'
end
end
......
# Encoding: utf-8
#
# Cookbook Name:: yum
# Attributes:: remi
......@@ -18,13 +19,13 @@
#
case node['platform']
when "fedora"
when 'fedora'
default['yum']['remi']['url'] = "http://rpms.famillecollet.com/fedora/#{node['platform_version'].to_i}/remi/mirror"
else
default['yum']['remi']['url'] = "http://rpms.famillecollet.com/enterprise/#{node['platform_version'].to_i}/remi/mirror"
end
default['yum']['remi']['key'] = "RPM-GPG-KEY-remi"
default['yum']['remi']['key'] = 'RPM-GPG-KEY-remi'
default['yum']['remi']['key_url'] = "http://rpms.famillecollet.com/#{node['yum']['remi']['key']}"
default['yum']['remi']['includepkgs'] = nil
default['yum']['remi']['exclude'] = nil
# Encoding: utf-8
#
# Cookbook Name:: yum
# Recipe:: default
......@@ -19,10 +20,10 @@
require File.expand_path('../support/helpers', __FILE__)
describe "yum::default" do
describe 'yum::default' do
include Helpers::YumTest
it "Default recipe does nothing, so default_test does nothing" do
skip "Default recipe does nothing so default test does nothing"
it 'Default recipe does nothing, so default_test does nothing' do
skip 'Default recipe does nothing so default test does nothing'
end
end
# Encoding: utf-8
#
# Cookbook Name:: yum_test
# Recipe:: default
......@@ -17,7 +18,11 @@
# limitations under the License.
#
# an comment
# Helpers
module Helpers
# Yumtest
module YumTest
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
......@@ -31,7 +36,7 @@ module Helpers
# end of the successful run, to cache the output to a file and
# inspect its contents.
def repo_enabled(repo)
shell_out("yum repolist enabled --verbose | grep Repo-id").stdout.include?(repo)
shell_out('yum repolist enabled --verbose | grep Repo-id').stdout.include?(repo)
end
end
end
# Encoding: utf-8
#
# Cookbook Name:: yum
#
......@@ -18,42 +19,42 @@
require File.expand_path('../support/helpers', __FILE__)
describe "yum::test" do
describe 'yum::test' do
# helpers includes the repo_enabled method used to test that repos
# are in fact enabled.
include Helpers::YumTest
describe "elrepo" do
it "enables the elrepo repository" do
assert(repo_enabled("elrepo"))
describe 'elrepo' do
it 'enables the elrepo repository' do
assert(repo_enabled('elrepo'))
end
end
describe "epel" do
it "enables the epel repository" do
assert(repo_enabled("epel"))
describe 'epel' do
it 'enables the epel repository' do
assert(repo_enabled('epel'))
end
end
describe "ius" do
it "enables the ius repository" do
assert(repo_enabled("ius"))
describe 'ius' do
it 'enables the ius repository' do
assert(repo_enabled('ius'))
end
end
describe "remi" do
it "enables the remi repository" do
assert(repo_enabled("remi"))
describe 'remi' do
it 'enables the remi repository' do
assert(repo_enabled('remi'))
end
end
describe "repoforge" do
it "enables the repoforge repository" do
assert(repo_enabled("rpmforge"))
describe 'repoforge' do
it 'enables the repoforge repository' do
assert(repo_enabled('rpmforge'))
end
end
end
describe "cook-2121" do
describe 'cook-2121' do
it 'doesnt update the zenos-add.repo file if it exists' do
assert File.zero?('/etc/yum.repos.d/zenoss-add.repo')
......@@ -64,9 +65,9 @@ describe "yum::test" do
end
end
describe "cook-3025" do
describe 'cook-3025' do
it 'doesnt add proxy statements to repositories if not specified' do
file('/etc/yum.repos.d/epel.repo').wont_match %r[^proxy=]
file('/etc/yum.repos.d/epel.repo').wont_match(/^proxy=/)
end
it 'does configure a proxy in repositories where it is specified' do
......
name "yum"
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Configures various yum components on Red Hat-like systems"
# Encoding: utf-8
name 'yum'
maintainer 'Opscode, Inc.'
maintainer_email 'cookbooks@opscode.com'
license 'Apache 2.0'
description 'Configures various yum components on Red Hat-like systems'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "2.4.3"
recipe "yum", "Empty recipe."
recipe "yum::yum", "Manages yum configuration"
version '2.4.3'
recipe 'yum', 'Empty recipe.'
recipe 'yum::yum', 'Manages yum configuration'
%w{ redhat centos scientific amazon }.each do |os|
supports os, ">= 5.0"
supports os, '>= 5.0'
end
attribute "yum/exclude",
:display_name => "yum.conf exclude",
:description => "List of packages to exclude from updates or installs. This should be an array. Shell globs using wildcards (eg. * and ?) are allowed.",
:required => "optional"
attribute 'yum/exclude',
display_name: 'yum.conf exclude',
description: 'List of packages to exclude from updates or installs. This should be an array. Shell globs using wildcards (eg. * and ?) are allowed.',
required: 'optional'
attribute "yum/installonlypkgs",
:display_name => "yum.conf installonlypkgs",
:description => "List of packages that should only ever be installed, never updated. Kernels in particular fall into this category. Defaults to kernel, kernel-smp, kernel-bigmem, kernel-enterprise, kernel-debug, kernel-unsupported.",
:required => "optional"
attribute 'yum/installonlypkgs',
display_name: 'yum.conf installonlypkgs',
description: 'List of packages that should only ever be installed, never updated. Kernels in particular fall into this category. Defaults to kernel, kernel-smp, kernel-bigmem, kernel-enterprise, kernel-debug, kernel-unsupported.',
required: 'optional'
attribute "yum/proxy",
:display_name => "yum.conf proxy",
:description => "Set the http URL for proxy to use in yum.conf",
:required => "optional"
attribute 'yum/proxy',
display_name: 'yum.conf proxy',
description: 'Set the http URL for proxy to use in yum.conf',
required: 'optional'
attribute "yum/proxy_username",
:display_name => "yum.conf proxy_username",
:description => "Set the proxy_username to use for yum.conf",
:required => "optional"
attribute 'yum/proxy_username',
display_name: 'yum.conf proxy_username',
description: 'Set the proxy_username to use for yum.conf',
required: 'optional'
attribute "yum/proxy_password",
:display_name => "yum.conf proxy_password",
:description => "Set the proxy_password to use for yum.conf",
:required => "optional"
attribute 'yum/proxy_password',
display_name: 'yum.conf proxy_password',
description: 'Set the proxy_password to use for yum.conf',
required: 'optional'
# Encoding: utf-8
#
# Cookbook Name:: yum
# Provider:: key
......@@ -27,9 +28,9 @@ action :add do
Chef::Log.info "Adding #{new_resource.key} GPG key to /etc/pki/rpm-gpg/"
if node['platform_version'].to_i <= 5
package "gnupg"
package 'gnupg'
elsif node['platform_version'].to_i >= 6
package "gnupg2"
package 'gnupg2'
end
execute "import-rpm-gpg-key-#{new_resource.key}" do
......@@ -56,11 +57,11 @@ action :add do
EOH
end
#download the file if necessary
# download the file if necessary
unless new_resource.url.nil?
remote_file "/etc/pki/rpm-gpg/#{new_resource.key}" do
source new_resource.url
mode "0644"
mode '0644'
notifies :run, "execute[import-rpm-gpg-key-#{new_resource.key}]", :immediately
end
end
......
# Encoding: utf-8
#
# Cookbook Name:: yum
# Provider:: repository
......@@ -56,10 +57,10 @@ action :update do
file.each_line do |line|
case line
when /^\[(\S+)\]/
repo_name = $1
repo_name = Regexp.last_match[1]
repos[repo_name] ||= {}
when /^(\S+?)=(.*)$/
param, value = $1, $2
param, value = Regexp.last_match[1], Regexp.last_match[2]
repos[repo_name][param] = value
else
end
......@@ -68,7 +69,7 @@ action :update do
else
Chef::Log.error "Repo /etc/yum.repos.d/#{new_resource.repo_name}.repo does not exist, you must create it first"
end
if !repos.has_key?(new_resource.repo_name) || repos[new_resource.repo_name]['enabled'].to_i != new_resource.enabled
if !repos.key?(new_resource.repo_name) || repos[new_resource.repo_name]['enabled'].to_i != new_resource.enabled
Chef::Log.info "Updating #{new_resource.repo_name} repository in /etc/yum.repos.d/#{new_resource.repo_name}.repo (setting enabled=#{new_resource.enabled})"
repo_config
else
......@@ -79,49 +80,49 @@ end
private
def repo_config
#import the gpg key. If it needs to be downloaded or imported from a cookbook
#that can be done in the calling recipe
# import the gpg key. If it needs to be downloaded or imported from a cookbook
# that can be done in the calling recipe
if new_resource.key then
yum_key "#{new_resource.repo_name}-key" do
key new_resource.key
end
end
#get the metadata for this repo only
# get the metadata for this repo only
execute "yum-makecache-#{new_resource.repo_name}" do
command "yum -q makecache --disablerepo=* --enablerepo=#{new_resource.repo_name}"
action :nothing
end
#reload internal Chef yum cache
# reload internal Chef yum cache
ruby_block "reload-internal-yum-cache-for-#{new_resource.repo_name}" do
block do
Chef::Provider::Package::Yum::YumCache.instance.reload
end
action :nothing
end
#write out the file
# write out the file
template "/etc/yum.repos.d/#{new_resource.repo_name}.repo" do
cookbook "yum"
source "repo.erb"
mode "0644"
variables({
:repo_name => new_resource.repo_name,
:description => new_resource.description,
:url => new_resource.url,
:mirrorlist => new_resource.mirrorlist,
:key => new_resource.key,
:enabled => new_resource.enabled,
:type => new_resource.type,
:failovermethod => new_resource.failovermethod,
:bootstrapurl => new_resource.bootstrapurl,
:includepkgs => new_resource.includepkgs,
:exclude => new_resource.exclude,
:priority => new_resource.priority,
:metadata_expire => new_resource.metadata_expire,
:type => new_resource.type,
:proxy => new_resource.proxy,
:proxy_username => new_resource.proxy_username,
:proxy_password => new_resource.proxy_password
})
cookbook 'yum'
source 'repo.erb'
mode '0644'
variables(
repo_name: new_resource.repo_name,
description: new_resource.description,
url: new_resource.url,
mirrorlist: new_resource.mirrorlist,
key: new_resource.key,
enabled: new_resource.enabled,
type: new_resource.type,
failovermethod: new_resource.failovermethod,
bootstrapurl: new_resource.bootstrapurl,
includepkgs: new_resource.includepkgs,
exclude: new_resource.exclude,
priority: new_resource.priority,
metadata_expire: new_resource.metadata_expire,
type: new_resource.type,
proxy: new_resource.proxy,
proxy_username: new_resource.proxy_username,
proxy_password: new_resource.proxy_password
)
if new_resource.make_cache
notifies :run, "execute[yum-makecache-#{new_resource.repo_name}]", :immediately
notifies :create, "ruby_block[reload-internal-yum-cache-for-#{new_resource.repo_name}]", :immediately
......
# Encoding: utf-8
#
# Cookbook Name:: yum
# Recipe:: default
......
# Encoding: utf-8
#
# Cookbook Name:: yum
# Recipe:: elrepo
......@@ -21,8 +22,8 @@ yum_key node['yum']['elrepo']['key'] do
action :add
end
yum_repository "elrepo" do
description "ELRepo.org Community Enterprise Linux Extras Repository"
yum_repository 'elrepo' do
description 'ELRepo.org Community Enterprise Linux Extras Repository'
key node['yum']['elrepo']['key']
mirrorlist node['yum']['elrepo']['url']
includepkgs node['yum']['elrepo']['includepkgs']
......
# Encoding: utf-8
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Cookbook Name:: yum
......@@ -24,8 +25,8 @@ yum_key node['yum']['epel']['key'] do
action :add
end
yum_repository "epel" do
description "Extra Packages for Enterprise Linux"
yum_repository 'epel' do
description 'Extra Packages for Enterprise Linux'
key node['yum']['epel']['key']
url node['yum']['epel']['baseurl']
mirrorlist node['yum']['epel']['url']
......
# Encoding: utf-8
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Cookbook Name:: yum
......@@ -17,9 +18,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_recipe "yum::epel"
include_recipe 'yum::epel'
package "epel-release"
package 'epel-release'
major = node['platform_version'].to_i
ius = node['yum']['ius_release']
......@@ -27,16 +28,16 @@ ius = node['yum']['ius_release']
remote_file "#{Chef::Config[:file_cache_path]}/ius-release-#{ius}.ius.el#{major}.noarch.rpm" do
source "http://dl.iuscommunity.org/pub/ius/stable/Redhat/#{major}/i386/ius-release-#{ius}.ius.el#{major}.noarch.rpm"
not_if "rpm -qa | grep -q '^ius-release-#{ius}'"
notifies :install, "rpm_package[ius-release]", :immediately
notifies :install, 'rpm_package[ius-release]', :immediately
end
rpm_package "ius-release" do
rpm_package 'ius-release' do
source "#{Chef::Config[:file_cache_path]}/ius-release-#{ius}.ius.el#{major}.noarch.rpm"
only_if { ::File.exists?("#{Chef::Config[:file_cache_path]}/ius-release-#{ius}.ius.el#{major}.noarch.rpm") }
action :nothing
end
file "ius-release-cleanup" do
file 'ius-release-cleanup' do
path "#{Chef::Config[:file_cache_path]}/ius-release-#{ius}.ius.el#{major}.noarch.rpm"
action :delete
end
# Encoding: utf-8
#
# Author:: Takeshi KOMIYA (<i.tkomiya@gmail.com>)
# Cookbook Name:: yum
......@@ -17,18 +18,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_recipe "yum::epel"
include_recipe 'yum::epel'
yum_key node['yum']['remi']['key'] do
url node['yum']['remi']['key_url']
action :add
end
yum_repository "remi" do
yum_repository 'remi' do
description "Les RPM de remi pour Enterprise Linux #{node['platform_version']} - $basearch"
key node['yum']['remi']['key']
mirrorlist node['yum']['remi']['url']
failovermethod "priority"
failovermethod 'priority'
includepkgs node['yum']['remi']['includepkgs']
exclude node['yum']['remi']['exclude']
action :create
......
# Encoding: utf-8
#
# Author:: Eric Edgar (<rocketman110@gmail.com>)
# Cookbook Name:: yum
......@@ -17,25 +18,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_recipe "yum::epel"
include_recipe 'yum::epel'
major = platform?("amazon") ? 6 : node['platform_version'].to_i
arch = (node['kernel']['machine'] == "i686" && major == 5) ? "i386" : node['kernel']['machine']
arch = (node['kernel']['machine'] == 'i686' && major == 5) ? 'i386' : node['kernel']['machine']
repoforge = node['yum']['repoforge_release']
remote_file "#{Chef::Config[:file_cache_path]}/rpmforge-release-#{repoforge}.el#{major}.rf.#{arch}.rpm" do
source "http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-#{repoforge}.el#{major}.rf.#{arch}.rpm"
not_if "rpm -qa | grep -q '^rpmforge-release-#{repoforge}'"
notifies :install, "rpm_package[rpmforge-release]", :immediately
notifies :install, 'rpm_package[rpmforge-release]', :immediately
end
rpm_package "rpmforge-release" do
rpm_package 'rpmforge-release' do
source "#{Chef::Config[:file_cache_path]}/rpmforge-release-#{repoforge}.el#{major}.rf.#{arch}.rpm"
only_if { ::File.exists?("#{Chef::Config[:file_cache_path]}/rpmforge-release-#{repoforge}.el#{major}.rf.#{arch}.rpm") }
action :install
end
file "repoforge-release-cleanup" do
file 'repoforge-release-cleanup' do
path "#{Chef::Config[:file_cache_path]}/rpmforge-release-#{repoforge}.el#{major}.rf.#{arch}.rpm"
action :delete
end
# Encoding: utf-8
#
# Cookbook:: yum
# Recipe:: test
......@@ -18,12 +19,12 @@
# limitations under the License.
#
include_recipe "yum::epel"
include_recipe "yum::elrepo"
include_recipe "yum::ius"
include_recipe "yum::repoforge"
include_recipe "yum::yum"
include_recipe "yum::remi"
include_recipe 'yum::epel'
include_recipe 'yum::elrepo'
include_recipe 'yum::ius'
include_recipe 'yum::repoforge'
include_recipe 'yum::yum'
include_recipe 'yum::remi'
%w{add create}.each do |act|
file "/etc/yum.repos.d/zenoss-#{act}.repo" do
......@@ -31,17 +32,17 @@ include_recipe "yum::remi"
end
yum_repository "zenoss-#{act}" do
description "Zenoss Stable repo"
url "http://dev.zenoss.com/yum/stable/"
key "RPM-GPG-KEY-zenoss"
description 'Zenoss Stable repo'
url 'http://dev.zenoss.com/yum/stable/'
key 'RPM-GPG-KEY-zenoss'
action act.to_sym
end
end
yum_repository "cook-3025" do
description "cook-3025"
url "http://example.invalid"
yum_repository 'cook-3025' do
description 'cook-3025'
url 'http://example.invalid'
enabled 0
make_cache false
proxy "http://proxy.invalid:1234/path"
proxy 'http://proxy.invalid:1234/path'
end
# Encoding: utf-8
#
# Cookbook Name:: yum
# Recipe:: yum
......@@ -18,6 +19,6 @@
# limitations under the License.
#
template "/etc/yum.conf" do
template '/etc/yum.conf' do