Skip to content

Commit

Permalink
COOK-1772
Browse files Browse the repository at this point in the history
* [COOK-1772] - Simplify management of EPEL with LWRP

When I first authored the yumrepo cookbook, Matt Ray was of the opinion that managing repository files was not something the Yum cookbook should enforce. Rather that cookbook should merely provide an LWRP for configuring repo files. Since then, the yum::epel recipe has evolved into something contrary to the design of its own cookbook. This particular recipe is mixing RPM managed repo files with LWRP managed repo files.

I happen to have been maintaining an EPEL recipe in my yumrepo cookbook all along, which does follow this method of using the LWRP to manage every repo file. Using the LWRP allows you to focus on fixing issues which creep up in the LWRP without having to track every single version of EPEL. As a bonus, this is a sanity check that your LWRP is working. Since this blocks idem-potency on systems using both yum::epel and yumrepo::epel, I motion to adopt the LWRP-EPEL version of the recipe as the better pattern. I will deprecate yumrepo::epel in turn, once this is merged so that further recipe conflict in the future is avoided.

[root@lists ~]# chef-client
[2012-10-15T15:57:02-04:00] INFO: *** Chef 10.14.4 ***
[2012-10-15T15:57:03-04:00] INFO: Run List is [recipe[yum::epel]]
[2012-10-15T15:57:03-04:00] INFO: Run List expands to [yum::epel]
[2012-10-15T15:57:03-04:00] INFO: Starting Chef Run for lists.marshall.edu
[2012-10-15T15:57:03-04:00] INFO: Running start handlers
[2012-10-15T15:57:03-04:00] INFO: Start handlers complete.
[2012-10-15T15:57:03-04:00] INFO: Loading cookbooks [yum]
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/resources/key.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/resources/repository.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/providers/key.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/providers/repository.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/recipes/epel.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/recipes/repoforge.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/attributes/epel.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/attributes/default.rb in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/Gemfile in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/CHANGELOG.md in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/README.md in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/.gitignore in the cache.
[2012-10-15T15:57:05-04:00] INFO: Storing updated cookbooks/yum/metadata.rb in the cache.
[2012-10-15T15:57:06-04:00] INFO: Chef Run complete in 2.318346333 seconds
[2012-10-15T15:57:06-04:00] INFO: Removing cookbooks/yum/metadata.json from the cache; it is no longer needed by chef-client.
[2012-10-15T15:57:06-04:00] INFO: Removing cookbooks/yum/templates/default/yum-rhel5.conf.erb from the cache; it is no longer needed by chef-client.
[2012-10-15T15:57:06-04:00] INFO: Running report handlers
[2012-10-15T15:57:06-04:00] INFO: Report handlers complete

[root@lists ~]# cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
  • Loading branch information
Eric G. Wolfe committed Oct 15, 2012
1 parent cdb27c9 commit 825b397
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## COOK-1772

* [COOK-1772] - Simplify management of EPEL with LWRP

## v1.0.0:

`mirrorlist` in the `yum_repository` LWRP must be set to the mirror
Expand Down
9 changes: 0 additions & 9 deletions attributes/default.rb
Expand Up @@ -21,15 +21,6 @@
# Example: override.yum.exclude = "kernel* compat-glibc*"
default['yum']['exclude'] = Array.new
default['yum']['installonlypkgs'] = Array.new

default['yum']['epel_release'] = case node['platform_version'].to_i
when 6
"6-7"
when 5
"5-4"
when 4
"4-10"
end
default['yum']['ius_release'] = '1.0-10'
default['yum']['repoforge_release'] = '0.5.2-2'
default['yum']['proxy'] = ''
Expand Down
28 changes: 28 additions & 0 deletions attributes/epel.rb
@@ -0,0 +1,28 @@
#
# Cookbook Name:: yumrepo
# Attributes:: epel
#
# Copyright 2011, Eric G. Wolfe
# Copyright 2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default['yum']['epel']['url'] = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-#{node['platform_version'].to_i}&arch=$basearch"

if node['platform_version'].to_i >= 6
set['yum']['epel']['key'] = "RPM-GPG-KEY-EPEL-6"
else
set['yum']['epel']['key'] = "RPM-GPG-KEY-EPEL"
end
default['yum']['epel']['key_url'] = "http://download.fedoraproject.org/pub/epel/#{node['yum']['epel']['key']}"
46 changes: 12 additions & 34 deletions recipes/epel.rb
Expand Up @@ -4,6 +4,8 @@
# Recipe:: epel
#
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# Copyright 2010, Eric G. Wolfe
# Copyright 2010, Tippr Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,39 +19,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if platform?("amazon")
# Enable the amazon-provided epel repository
execute "enable-epel-repository" do
command "yum-config-manager --quiet --enable epel"
end

else
major = node['platform_version'].to_i
epel = node['yum']['epel_release']
if node['kernel']['machine'] == "i686"
rpm_arch = "i386"
else
rpm_arch = node['kernel']['machine']
end

# If rpm installation from a URL supported 302's, we'd just use that.
# Instead, we get to remote_file then rpm_package.

remote_file "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm" do
source "http://dl.fedoraproject.org/pub/epel/#{major}/#{rpm_arch}/epel-release-#{epel}.noarch.rpm"
not_if "rpm -qa | egrep -qx 'epel-release-#{epel}(|.noarch)'"
notifies :install, "rpm_package[epel-release]", :immediately
retries 5 # We may be redirected to a FTP URL, CHEF-1031.
end

rpm_package "epel-release" do
source "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm"
only_if {::File.exists?("#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm")}
action :nothing
end
yum_key node['repo']['epel']['key'] do
url node['repo']['epel']['key_url']
action :add
end

file "epel-release-cleanup" do
path "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm"
action :delete
end
yum_repository "epel" do
description "Extra Packages for Enterprise Linux"
key node['repo']['epel']['key']
url node['repo']['epel']['url']
mirrorlist true
action :add
end

0 comments on commit 825b397

Please sign in to comment.