Sha256: ec7ba15afc9fd15701a07027d828304632bfe0eb457e5faa0ac5cc42832d8b3e

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

require 'chef/provider/lwrp_base'
require 'cheffish/cheffish_server_api'

class Chef::Provider::MachineExecute < Chef::Provider::LWRPBase

  use_inline_resources

  def whyrun_supported?
    true
  end

  def machine
    @machine ||= begin
      if new_resource.machine.kind_of?(ChefMetal::Machine)
        new_resource.machine
      else
        # TODO this is inefficient, can we cache or something?
        node = Cheffish::CheffishServerAPI.new(new_resource.chef_server).get("/nodes/#{new_resource.machine}")
        new_resource.provisioner.connect_to_machine(node)
      end
    end
  end

  action :run do
    machine.execute(self, new_resource.command)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef-metal-0.8.2 lib/chef/provider/machine_execute.rb
chef-metal-0.8.1 lib/chef/provider/machine_execute.rb
chef-metal-0.8 lib/chef/provider/machine_execute.rb