voxpupuli / puppet-wget

A puppet recipe for wget, a useful tool to download arbitary files from the web
Apache License 2.0
41 stars 114 forks source link

Could not retrieve information from environment production source #34

Open danielburrell opened 10 years ago

danielburrell commented 10 years ago

Hi, when performing the following sequence I get the error shown:

root@localhost:/opt# cat d wget::fetch { 'jungle': source => 'https://www.dropbox.com/s/brk7zeszv3a8k2o/jungle.deb?dl=1', destination => '/home/dan/jungle.deb', cache_dir => '/var/cache/wget', cache_file => 'jungle.deb', }

root@localhost:/opt# puppet apply d Notice: Compiled catalog for localhost.members.linode.com in environment production in 0.20 seconds Notice: /Stage[main]/Main/Wget::Fetch[jungle]/Exec[wget-jungle]/returns: executed successfully Error: /Stage[main]/Main/Wget::Fetch[jungle]/File[/home/dan/jungle.deb]: Could not evaluate: Could not retrieve information from environment production source(s) file:/var/cache/wget/jungle.deb Notice: Finished catalog run in 2.97 seconds

carlossg commented 10 years ago

/home/dan, /var/cache/wget/ exist? try with --debug

kgeis commented 9 years ago

I'm having the same problem. This is happening because it gets cached as /var/cache/wget/jungle.deb?dl=1 and then it fails to find it in the cache as jungle.deb.

enemarke commented 9 years ago

This is happening because wget. When wget uses options -N and -P it does not support --output-document and the $cache_file is not being used in the wget command. When puppet tries to create the file is will look for a file named like $cache_file, which does not exist. Leaving out the $cache_file will work in cases where the wget url does not include a query path.

in fetch.pp line 141 the $cache_file only takes the path from the wget url and not the query. I have tried updating the line to:

undef   => inline_template('<%= require \'uri\'; require \'shellwords\'; File.basename(URI::parse(@source).path) -%>?<%= Shellwords.shellescape(File.basename(URI::parse(@source).query))-%>'),

But I cannot make it to work. Puppet complains about the escaped path and without the escaping linux cannot find the file.

Possible hack would be to make an exec that copies the cached file to a file name that puppet can handle. Also note that the above will fail if the wget url does not have a query part. This should also be taken into consideration.