What you are looking for is a loop which does not exist in puppet, except
for templates. 

I've never tried it but I've speculated it could be possible to create a
manifest template and then use puppet to generate that manifest file in a
similar fashion you are looking to do.

-----Original Message-----
From: puppet-users@googlegroups.com [mailto:puppet-us...@googlegroups.com]
On Behalf Of luke.bigum
Sent: Wednesday, November 10, 2010 10:19 AM
To: Puppet Users
Subject: [Puppet Users] use current array element when declaring multiple
resources using an array

Hi list,

When declaring multiple resources at once with an array like this:

file { [ "foo", "bar" ]: ... }

Is there a way to access the current array element so as to pass this
value as a parameter? So the "foo" resource has a parameter value
"foo" and "bar" with a parameter value "bar"?

This is a broken example showing that Puppet looks to be evaluating
"owner => $array1" in it's entirety (and perhaps only taking the first
element for a File resource?):

  $array1 = [ "/tmp/one", "/tmp/two", "/tmp/three" ]
  file { $array1:
    ensure => present,
    owner => $array1,
  }

err: /Stage[main]/Test/File[/tmp/three]: Could not evaluate: Could not
find user /tmp/one
err: /Stage[main]/Test/File[/tmp/two]: Could not evaluate: Could not
find user /tmp/one
err: /Stage[main]/Test/File[/tmp/one]: Could not evaluate: Could not
find user /tmp/one

What I want to see is:

err: /Stage[main]/Test/File[/tmp/three]: Could not evaluate: Could not
find user /tmp/three
err: /Stage[main]/Test/File[/tmp/two]: Could not evaluate: Could not
find user /tmp/two
err: /Stage[main]/Test/File[/tmp/one]: Could not evaluate: Could not
find user /tmp/one

Is there an equivalent of Perl's $_ variable? Perhaps with some
inline_template Ruby magic? This would make some config I'm trying to
write a great deal more concise.

-- 
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to