Class: Chef::Provider::RemoteRecipe

Inherits:
Chef::Provider show all
Defined in:
lib/chef/providers/remote_recipe_provider.rb

Overview

RemoteRecipe chef provider.

Instance Method Summary collapse

Instance Method Details

#action_runObject

Actually run RemoteRecipe

Return

true

Always return true



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/chef/providers/remote_recipe_provider.rb', line 42

def action_run
  tags          = @new_resource.recipients_tags
  recipients    = @new_resource.recipients
  agent_options = RightScale::OptionsBag.load
  attributes    = { :remote_recipe => { :tags => tags,
                                        :from => agent_options[:identity] } }
  attributes.merge!(@new_resource.attributes) if @new_resource.attributes
  payload = { :recipe => @new_resource.recipe, :json => attributes.to_json }
  if recipients && !recipients.empty?
    target = if (s = recipients.size) == 1
               'one remote instance'
             else
               "#{s} remote instances"
             end
    Chef::Log.info("Scheduling execution of #{@new_resource.recipe.inspect} on #{target}")
    recipients.each do |recipient|
      RightScale::Cook.instance.send_push('/instance_scheduler/execute', payload, recipient)
    end
  end
  if tags && !tags.empty?
    selector = (@new_resource.scope == :single ? :any : :all)
    target_tag = if tags.size == 1
                   "tag #{tags.first.inspect}"
                 else
                   "tags #{tags.map { |t| t.inspect }.join(', ') }"
                 end
    target = if selector == :all
               "all instances with #{target_tag}"
             else
               "one instance with #{target_tag}"
             end
    Chef::Log.info("Scheduling execution of #{@new_resource.recipe.inspect} on #{target}")
    RightScale::Cook.instance.send_push('/instance_scheduler/execute', payload, {:tags => tags, :selector => selector})
  end
  true
end

#load_current_resourceObject

No concept of a ‘current’ resource for RemoteRecipe execution, this is a no-op

Return

true

Always return true



34
35
36
# File 'lib/chef/providers/remote_recipe_provider.rb', line 34

def load_current_resource
  true
end