Sha256: 100a4803eb5292742c313c1d43c34ef5b0c781d55c013394a09450f0bd5e1e33

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

require 'chef/provider/lwrp_base'
require 'chef/provisioning/chef_provider_action_handler'
require 'chef/provisioning/machine'

class Chef
class Provider
class MachineFile < Chef::Provider::LWRPBase

  def action_handler
    @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
  end

  use_inline_resources

  def whyrun_supported?
    true
  end

  def machine
    @machine ||= begin
      if new_resource.machine.kind_of?(Chef::Provisioning::Machine)
        new_resource.machine
      else
        run_context.chef_provisioning.connect_to_machine(new_resource.machine, new_resource.chef_server)
      end
    end
  end

  action :upload do
    if new_resource.content
      machine.write_file(action_handler, new_resource.path, new_resource.content)
    else
      machine.upload_file(action_handler, new_resource.local_path, new_resource.path)
    end

    attributes = {}
    attributes[:group] = new_resource.group if new_resource.group
    attributes[:owner] = new_resource.owner if new_resource.owner
    attributes[:mode] = new_resource.mode if new_resource.mode

    machine.set_attributes(action_handler, new_resource.path, attributes)
  end

  action :download do
    machine.download_file(action_handler, new_resource.path, new_resource.local_path)
  end

  action :delete do
    machine.delete_file(action_handler, new_resource.path)
  end

end
end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
chef-provisioning-1.3.0 lib/chef/provider/machine_file.rb
chef-provisioning-1.2.1 lib/chef/provider/machine_file.rb
chef-provisioning-1.2.0 lib/chef/provider/machine_file.rb
chef-provisioning-1.1.1 lib/chef/provider/machine_file.rb
chef-provisioning-1.1.0 lib/chef/provider/machine_file.rb
chef-provisioning-1.0.1 lib/chef/provider/machine_file.rb
chef-provisioning-1.0.0 lib/chef/provider/machine_file.rb
chef-provisioning-1.0.0.rc.2 lib/chef/provider/machine_file.rb
chef-provisioning-0.20.1 lib/chef/provider/machine_file.rb
chef-provisioning-1.0.0.rc.1 lib/chef/provider/machine_file.rb
chef-provisioning-0.20 lib/chef/provider/machine_file.rb
chef-provisioning-0.19 lib/chef/provider/machine_file.rb
chef-provisioning-0.18 lib/chef/provider/machine_file.rb
chef-provisioning-0.17 lib/chef/provider/machine_file.rb
chef-provisioning-0.16 lib/chef/provider/machine_file.rb
chef-provisioning-0.15.3 lib/chef/provider/machine_file.rb
chef-provisioning-0.15.2 lib/chef/provider/machine_file.rb
chef-provisioning-0.15.1 lib/chef/provider/machine_file.rb
chef-provisioning-0.15 lib/chef/provider/machine_file.rb