Skip to content

Commit

Permalink
Fix up chef_gem immediate execution
Browse files Browse the repository at this point in the history
- Uses Chef::Resource.after_created hook to trigger Chef::Resource.run_action
    This inadvertently prevents any notifications by skipping Chef::Runner.run_action
- Falls back to find_gem_by_path only if we are on omnibus and using gem_package (not chef_gem)
  • Loading branch information
btm committed Feb 1, 2012
1 parent fc82b6b commit 1fb9424
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion chef/lib/chef/provider/package/rubygems.rb
Expand Up @@ -312,7 +312,7 @@ def initialize(new_resource, run_context=nil)
end
@gem_env = AlternateGemEnvironment.new(new_resource.gem_binary)
Chef::Log.debug("#{@new_resource} using gem '#{new_resource.gem_binary}'")
elsif is_omnibus?
elsif is_omnibus? && (!@new_resource.instance_of? Chef::Resource::ChefGem)
# Opscode Omnibus - The ruby that ships inside omnibus is only used for Chef
# Default to installing somewhere more functional
gem_location = find_gem_by_path
Expand Down
28 changes: 6 additions & 22 deletions chef/lib/chef/resource/chef_gem.rb
Expand Up @@ -40,29 +40,13 @@ def gem_binary(arg=nil)
nil
end

def action(arg=nil)
if arg
action_list = arg.kind_of?(Array) ? arg : [ arg ]
action_list = action_list.collect { |a| a.to_sym }
action_list.each do |action|
validate(
{
:action => action,
},
{
:action => { :kind_of => Symbol, :equal_to => @allowed_actions },
}
)
end

# chef_gem actions should run immediately so that the result affects the recipe evaluation
action_list.each do |action|
self.run_action(action)
end
@action = action_list
else
@action
def after_created
# Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled
# Action could be an array of symbols, but probably won't (think install + enable for a package)
Array(@action).each do |action|
self.run_action(action)
end
Gem.clear_paths
end
end
end
Expand Down

0 comments on commit 1fb9424

Please sign in to comment.