/chef/cookbooks/yum/recipes/epel.rb

https://github.com/daihuaye/class2go · Ruby · 50 lines · 23 code · 6 blank · 21 comment · 1 complexity · d43788a3e9925dd0231801559ffd5ff8 MD5 · raw file

  1. #
  2. # Author:: Joshua Timberman (<joshua@opscode.com>)
  3. # Cookbook Name:: yum
  4. # Recipe:: epel
  5. #
  6. # Copyright:: Copyright (c) 2011 Opscode, Inc.
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. if platform?("amazon")
  20. # Enable the amazon-provided epel repository
  21. execute "enable-epel-repository" do
  22. command "yum-config-manager --quiet --enable epel"
  23. end
  24. else
  25. major = node['platform_version'].to_i
  26. epel = node['yum']['epel_release']
  27. # If rpm installation from a URL supported 302's, we'd just use that.
  28. # Instead, we get to remote_file then rpm_package.
  29. remote_file "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm" do
  30. source "http://download.fedoraproject.org/pub/epel/#{major}/i386/epel-release-#{epel}.noarch.rpm"
  31. not_if "rpm -qa | egrep -qx 'epel-release-#{epel}(|.noarch)'"
  32. notifies :install, "rpm_package[epel-release]", :immediately
  33. retries 5 # We may be redirected to a FTP URL, CHEF-1031.
  34. end
  35. rpm_package "epel-release" do
  36. source "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm"
  37. only_if {::File.exists?("#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm")}
  38. action :nothing
  39. end
  40. file "epel-release-cleanup" do
  41. path "#{Chef::Config[:file_cache_path]}/epel-release-#{epel}.noarch.rpm"
  42. action :delete
  43. end
  44. end