Re: [Puppet Users] Downloading files to Puppet clients from HTTP Server

5,257 views
Skip to first unread message

Darren Chamberlain

unread,
Aug 18, 2010, 8:30:48 PM8/18/10
to Puppet Users
* Ahmed El Gamil <ahmed at manhag.org> [2010/08/18 17:17]:
> I was working on some puppet recipe and came to the need where i
> want to download a file from an HTTP server, usually i use the
> "file" resource type with the "source" parameter to push files to
> the clients, but in this situation i just need to download the
> file directly from the HTTP server to the puppet client.
>
> By any chance, does the "source" parameter supports HTTP URLs, if
> not then how can i do that in Puppet ?

I use a simple define + wget for this kind of thing:

define download ($uri, $timeout = 300) {
exec {
"download $uri":
command => "wget -q '$uri' -O $name",
creates => $name,
timeout => $timeout,
require => Package[ "wget" ],
}
}

Use it like:

download {
"/tmp/tomcat.tar.gz":
uri => "http://www.ibiblio.org/pub/mirrors/apache/tomcat/tomcat-5/v5.5.30/bin/apache-tomcat-5.5.30.tar.gz",
timeout => 900;
}

--
It's a damn poor mind that can only think of one way to spell a word.

Ahmed El Gamil

unread,
Aug 18, 2010, 8:17:44 PM8/18/10
to Puppet Users
Hi,

I was working on some puppet recipe and came to the need where i want
to download a file from an HTTP server, usually i use the "file"
resource type with the "source" parameter to push files to the
clients, but in this situation i just need to download the file
directly from the HTTP server to the puppet client.

By any chance, does the "source" parameter supports HTTP URLs, if not
then how can i do that in Puppet ?

Thanks in advance

Craig Dunn

unread,
Aug 19, 2010, 5:38:39 AM8/19/10
to puppet...@googlegroups.com
By any chance, does the "source" parameter supports HTTP URLs, if not
then how can i do that in Puppet ?


Source currently only supports the "file" and "puppet" URI types, you could accomplish a  few ways, one is  with a simple exec....

exec { "wget http://myurl.com/file.txt -o /path/to/file.txt":
           creates  =>  "/path/to/file.txt",
}

Having "creates" will ensure that it doesn't run if the file already exists.

Craig



 

Patrick

unread,
Aug 19, 2010, 10:53:28 AM8/19/10
to puppet...@googlegroups.com
Just to clarify, if the remote file is changed, the client will not know to redownload the remote file.

Zsync might do what you want if you want the client's file to change if the remote file changes.
Reply all
Reply to author
Forward
0 new messages