Ask Your Question

Copy an array of files

asked 2017-03-07 04:44:20 -0600

bigfoot74 gravatar image


i think I have a pretty dumb question.. but somehow Im kinda stuck.. I want to copy some files from a server, I created an array of file:

$files = [ '/tmp/file1', /tmp/file2', ]

The download url is = So how do I copy multiple files from there. One file is easy, but multiple... I thought something like

file { $files: ensure => present, source => $download_url }

Somehow this does not work,or do I have to create a for each loop ?

Could someone help me please ?

kind regards,

  • Pascal
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-07 13:49:29 -0600

puser gravatar image
$binaries.each |String $binary| {
file {"/usr/bin/${binary}":
ensure => link,
target => "/opt/puppetlabs/bin/${binary}",

^ Example.

Replace binaries with your files array and binary with $file.

edit flag offensive delete link more


I was going to post a solution using an array and the prefix function because I am still stuck in puppet3 land and forget about nice things like the above...

DarylW gravatar imageDarylW ( 2017-03-14 08:45:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-03-07 04:44:20 -0600

Seen: 114 times

Last updated: Mar 07 '17