On 12/16/2011 08:07 AM, Alexandre wrote:
> Hi,
> If you find out how to do some kind of foreach() to iterate over a
> Puppet array, that's something i would to know
Hi,
there's not really a foreach. Instead you define a type and make an
instance of that for each array element.
$users = [ "john", "joe", "horst" ]
define user_with_repo() {
user { $name: ... }
vcsrepo { "repo-for-$name": ... }
}
# this is the "foreach":
users_with_repo { $users: }
Of course, this is harder if you need to supply individual data for each
user, e.g. an SSH key.
You would probably build a hash like $users = { name => key, ... },
and to create resources from that you need the create_resources
function, see
http://docs.puppetlabs.com/references/stable/function.html#createresources
HTH,
Felix
> On 14 déc, 13:35, Felix Frank <[email protected]> wrote:
>> Hi,
>>
>> On 12/13/2011 11:25 PM, Forrie wrote:
>>
>>> I thought I could just create a simple array and then use a file {}
>>> statement to ensure they are created. Seems simple enough. Some
>>> don't feel that's the most efficient way.
>>
>>> Since I'm going to be using autofs to ensure the mounts exist, I
>>> suppose I could craft a template which could make use of this array
>>> and then ship out the autofs configuration to each system, as a
>>> dependency.
>>
>> this sounds pretty good to me.
>>
>> Cheers,
>> Felix
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.