Chef 10: How to use a remote_file or similar to get a file from a Windows shared folder?

I am trying to use remote_fileto cache a local copy of a large package on a Windows share. How it's done?

I can't get it to work with a letter-based path based on a letter, UNC-based or URL-based file:.

0
source share
2 answers

I developed a trick that I find pretty neat. I created the following definition (and put it in definitions/default.rb):

define :file_from_network, :action => :create do
   myPath = (params[:path] || params[:name])
   mySource = params[:source]

   if File.exist?(mySource)
      file myPath do
         action params[:action]
         content File.open(mySource) {|io| io.read}
      end
   else
      Chef::Log.error("File #{mySource} not found!")
   end
end

, , , . , , Chef , , .

0

, - :

require 'fileutils'
remote_path = '...'
local_path = '...'

ruby "cache-#{remote_path}" do
    block  { FileUtils.copy_file(remote_path, local_path) }       
    not_if { File.exists?(local_path) }
end
+1

Source: https://habr.com/ru/post/1542272/


All Articles