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. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Sowc-6bIiOgJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
David Schmitt
2012-Jul-31 14:10 UTC
Re: [Puppet Users] Using file{} with array parameter fails
Hi Axel, On 31.07.2012 15:59, Axel Bock wrote:> 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?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 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Axel Bock
2012-Aug-01 06:16 UTC
Re: [Puppet Users] Using file{} with array parameter fails
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, > > > $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 >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/hgdnKnvvHGcJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.