Class: Chef::Provider::Package::Yum
- Inherits:
-
Chef::Provider::Package
- Object
- Chef::Provider
- Chef::Provider::Package
- Chef::Provider::Package::Yum
- Defined in:
- lib/chef/provider/package/yum.rb
Defined Under Namespace
Classes: YumCache
Instance Attribute Summary
Attributes inherited from Chef::Provider::Package
Attributes inherited from Chef::Provider
#current_resource, #new_resource, #node
Instance Method Summary collapse
-
#initialize(node, new_resource, collection = nil, definitions = nil, cookbook_loader = nil) ⇒ Yum
constructor
A new instance of Yum.
- #install_package(name, version) ⇒ Object
- #load_current_resource ⇒ Object
- #purge_package(name, version) ⇒ Object
- #remove_package(name, version) ⇒ Object
- #upgrade_package(name, version) ⇒ Object
Methods inherited from Chef::Provider::Package
#action_install, #action_purge, #action_remove, #action_upgrade, #expand_options, #get_preseed_file, #preseed_package, #should_remove_package
Methods included from Mixin::Command
handle_command_failures, not_if, only_if, output_of_command, popen4, run_command, run_command_with_systems_locale
Methods inherited from Chef::Provider
#action_nothing, build_from_file
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #filename_to_qualified_string
Methods included from Mixin::RecipeDefinitionDSLCore
Constructor Details
#initialize(node, new_resource, collection = nil, definitions = nil, cookbook_loader = nil) ⇒ Yum
Returns a new instance of Yum.
109 110 111 112 |
# File 'lib/chef/provider/package/yum.rb', line 109 def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil) @yum = YumCache.instance super(node, new_resource, collection, definitions, cookbook_loader) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
Instance Method Details
#install_package(name, version) ⇒ Object
135 136 137 138 139 140 |
# File 'lib/chef/provider/package/yum.rb', line 135 def install_package(name, version) run_command_with_systems_locale( :command => "yum -q -y install #{name}-#{version}" ) @yum.flush end |
#load_current_resource ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/chef/provider/package/yum.rb', line 114 def load_current_resource @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) Chef::Log.debug("Checking yum info for #{@new_resource.package_name}") @yum.refresh installed_version = @yum.installed_version(@new_resource.package_name) @candidate_version = @yum.candidate_version(@new_resource.package_name) @current_resource.version(installed_version) if candidate_version @candidate_version = candidate_version else @candidate_version = installed_version end @current_resource end |
#purge_package(name, version) ⇒ Object
168 169 170 |
# File 'lib/chef/provider/package/yum.rb', line 168 def purge_package(name, version) remove_package(name, version) end |
#remove_package(name, version) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/chef/provider/package/yum.rb', line 154 def remove_package(name, version) if version run_command_with_systems_locale( :command => "yum -q -y remove #{name}-#{version}" ) else run_command_with_systems_locale( :command => "yum -q -y remove #{name}" ) end @yum.flush end |
#upgrade_package(name, version) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/chef/provider/package/yum.rb', line 142 def upgrade_package(name, version) # If we have a version, we can upgrade - otherwise, install if @current_resource.version run_command_with_systems_locale( :command => "yum -q -y update #{name}-#{version}" ) @yum.flush else install_package(name, version) end end |