Using file{} with array parameter fails

80 views
Skip to first unread message

Axel Bock

unread,
Jul 31, 2012, 9:59:31 AM7/31/12
to puppet...@googlegroups.com
Hello readers,

I am wondering - I intend to create a few directory trees with the file{ [array] } pattern, but unfortunately Puppet complains. It says  "File[] is already declared in file ..." - which kind of looks like as if Puppet takes a file object with an array as parameter as a single, unnamed File object. I would assume this would be equivalent to

File{ array[0] : ... }
File{ array[1] : ... }
File{ array[2] : ... }

... etc. Unfortunately the directories should have different owners and permissions, so I cannot merge those into a single file{} statement. Any advice how I can achieve what I want without breaking this up into - right now - six different file{} delarations?

Thanks in advance & greetings,
Axel.

David Schmitt

unread,
Jul 31, 2012, 10:10:23 AM7/31/12
to puppet...@googlegroups.com
Hi Axel,
You're description is not totally clear to me, but here's an example how
arrays should work:


$filesA = ["/tmp/A1", "/tmp/A2", "/tmp/A3" ]
$filesB = ["/tmp/B1", "/tmp/B2", "/tmp/B3" ]

file {
$filesA:
ensure => present,
mode => 0644, owner => root;
$filesB:
ensure => present,
mode => 0755, owner => "www-data";
}

If you're looking for something different you might want to look into
setting recurse=>true. Read the Type Reference for more info.

Best Regards, David

Axel Bock

unread,
Aug 1, 2012, 2:16:12 AM8/1/12
to puppet...@googlegroups.com
thanks for the reply, I actually made an error in my declaration. I used two variables which I had just moved out of scope, and so I declared two empty File[] objects - and puppet complained.

When your solution didn't work either it hit me :) .

thanks & greetings!
Axel.



Am Dienstag, 31. Juli 2012 16:10:23 UTC+2 schrieb David Schmitt:
Hi Axel,
Reply all
Reply to author
Forward
0 new messages