Ask Your Question
0

Copy an array of files

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

bigfoot74 gravatar image

Hello,

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 = https://someurl.com 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
0

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

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

Comments

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 -0500 )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

Stats

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

Seen: 28 times

Last updated: Mar 07