0

I am trying to use windows share to copy files. Its working fine in windows where as it is giving error when i am using it linux.

remote_file 'download' do 
source 'file:////server/repo/client.zip' 
path "/etc/chef/client.zip" 
end

Error log

Errno::ENOENT ------------- No such file or directory @ rb_sysopen - /server/repo/client.zip

Resource Declaration: --------------------- 
# In 52: remote_file 'download' do 
53: source 'file:////server/repo/client.zip' 
54: path "/etc/chef/client.zip" 
56: end 
57: #end

SASI
  • 475
  • 2
  • 7
  • 16
  • Obvisouly linux has no clue to translate file:// which is supposed to be a local file to a cifs UNC path magically. You have to work around, mounting the target share, using the mount point as source and then umount it. – Tensibai Nov 25 '15 at 13:19
  • Thanks Tensibai. Also can you suggest best practice for maintaining packages(executables) which are used in chef automation. – SASI Nov 25 '15 at 17:11
  • There's the omnibus-updater cookbook which help keeping the chef client up to date – Tensibai Nov 25 '15 at 17:25
  • No I am asking about binaries used in cookbooks. For example java.exe and other softwares. I am planning to use file share. What are the best ways to store binaries. – SASI Nov 25 '15 at 23:17
  • Any kind of artifact repository, nexus, artifactory or a simple http Web server, it all depends on your workfow and your needs. usually a platform agnostic way, http is the best candidate IMO – Tensibai Nov 25 '15 at 23:21

2 Answers2

1

The fact that this works at all on UNC paths was kind of accidental (though lest anyone take that the wrong way it isn't going to be removed AFAIK). There isn't a similar pattern for Linux. You can use an execute resource and cp to cover the basic use case.

execute 'cp /from /to' do
  creates '/to'
end
coderanger
  • 52,400
  • 4
  • 52
  • 75
  • `File.read` and a `file` requires buffering the whole file in to memory, and `remote_file` buffers to a tempfile which can interfere with auto-NFS stuffs, which is the usual Linux equiv to CIFS network URIs. – coderanger Nov 25 '15 at 20:41
  • `creates` is a guard specific to `execute` and things descended from it. That is equivalent to `not_if { ::File.exist?('/to') }` – coderanger Nov 26 '15 at 00:24
  • Unsure what I read instead of creates a first... Now you said it, it sounds so obvious. Disregard previous comments, I'll clean them – Tensibai Nov 26 '15 at 06:46
0

Can you try:

remote_file 'download' do 
  source '\\server\repo\client.zip' 
  path "/etc/chef/client.zip" 
end

The remote_file resource supports windows network paths via the Chef::Provider::RemoteFile::NetworkFile class (if anyone wants to dig around in the source for more information).

The dispatcher under remote_file keys off of the leading double backwhacks '\\' so those characters must be backwhacks and not forward slashes. Note also that i'm using single quotes and not double quotes-if double quotes are used (for interpolation or just style) then the backwhacks need to be escaped themselves and it becomes source "\\\\server\\repo\\client.zip". I'm fairly certain that ruby itself will tolerate the rest of the backwhacks being changed to forward slashes (so source '\\server/repo/client.zip' might be legal?), but that looks awkward.

This feature was released first in 12.4.0 in https://github.com/chef/chef/pull/3336

lamont
  • 3,854
  • 1
  • 20
  • 26
  • - it should work. make sure you're using at least 12.4.0 and make sure you took off the file:// part of the url. – lamont Nov 28 '15 at 07:02