Module: Yum::RightScale::Epel
- Defined in:
- lib/repo_conf_generators/rightscale_conf_generators.rb
Defined Under Namespace
Modules: Testing
Class Method Summary collapse
-
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################.
- .generate(description, base_urls, frozen_date = "latest") ⇒ Object
-
.get_enterprise_linux_version ⇒ Object
Return the enterprise linux version of the running machine…or an exception if it’s a non-enterprise version of linux.
- .rightscale_gpgkey_imported? ⇒ Boolean
- .yum_installed? ⇒ Boolean
Class Method Details
.abstract_generate(params) ⇒ Object
INTERNAL FUNCTIONS #######################################################
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 62 def self.abstract_generate(params) return unless Yum::RightScale::Epel::yum_installed? epel_version = get_enterprise_linux_version puts "found EPEL version: #{epel_version}" opts = { :enabled => true, :frozen_date => "latest"} opts.merge!(params) raise "missing parameters to generate file!" unless opts[:repo_filename] && opts[:repo_name] && opts[:base_urls] && opts[:frozen_date] && opts[:enabled] arch = Yum::execute("uname -i").strip repo_path = "#{epel_version}/#{arch}/archive/"+opts[:frozen_date] mirror_list = opts[:base_urls].map do |bu| bu +='/' unless bu[-1..-1] == '/' # ensure the base url is terminated with a '/' bu+repo_path end gpgcheck = "1" unless Yum::RightScale::Epel::rightscale_gpgkey_imported? gpgfile = "/etc/pki/rpm-gpg/RPM-GPG-KEY-RightScale" if File.exists?(gpgfile) # This file should be installed by the rightimage cookbook # starting with 12H1 (May 2012) gpgkey = "file://#{gpgfile}" gpgcheck = "1" else gpgfile = File.("../rightscale_key.pub", __FILE__) Yum::execute("rpm --import #{gpgfile}") gpgcheck = "1" gpgkey = "" end end config_body = "[\#{opts[:repo_name]}]\nname = \#{opts[:description]}\nbaseurl = \#{mirror_list.join(\"\\n \")}\nfailovermethod=priority\ngpgcheck=\#{gpgcheck}\nenabled=\#{(opts[:enabled] ? 1:0)}\ngpgkey=\#{gpgkey}\n# set metadata to expire faster then main\nmetadata_expire=30\n" target_filename = "#{Yum::BaseRepositoryDir}/#{opts[:repo_filename]}.repo" File.rename(target_filename,"#{Yum::BaseRepositoryDir}/.#{opts[:repo_filename]}.repo.#{`date +%Y%m%d%M%S`.strip}") if File.exists?("#{Yum::BaseRepositoryDir}/#{opts[:repo_filename]}.repo") File.open(target_filename,'w') { |f| f.write(config_body) } puts "Yum config file for Epel successfully generated in #{target_filename}" mirror_list end |
.generate(description, base_urls, frozen_date = "latest") ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 38 def self.generate(description, base_urls, frozen_date = "latest") opts = {:repo_filename => "RightScale-epel", :repo_name => "rightscale-epel", :description => description, :base_urls => base_urls, :frozen_date => frozen_date, :enabled => true } opts[:frozen_date] = frozen_date || "latest" # Optional frozen date Yum::RightScale::Epel::abstract_generate(opts) end |
.get_enterprise_linux_version ⇒ Object
Return the enterprise linux version of the running machine…or an exception if it’s a non-enterprise version of linux. At this point we will only test for CentOS … but in the future we can test RHEL, and any other compatible ones Note the version is a single (major) number.
134 135 136 137 138 139 140 141 142 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 134 def self.get_enterprise_linux_version version=nil if Yum::RightScale::Epel::yum_installed? version = Yum::execute("lsb_release -rs").strip.split(".").first else raise "This doesn't appear to be an Enterprise Linux edition" end version end |
.rightscale_gpgkey_imported? ⇒ Boolean
122 123 124 125 126 127 128 129 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 122 def self.rightscale_gpgkey_imported? begin Yum::execute("rpm -qa gpg-pubkey --qf '%{summary}\n' | grep RightScale") true rescue false end end |
.yum_installed? ⇒ Boolean
114 115 116 117 118 119 120 |
# File 'lib/repo_conf_generators/rightscale_conf_generators.rb', line 114 def self.yum_installed? if ::RightScale::Platform.linux? && (::RightScale::Platform.centos? || ::RightScale::Platform.rhel?) true else false end end |