Thanks
--
M. Haris
On Thu, Feb 18, 2010 at 12:33 PM, Haris Farooque <mfh...@fleetboard.com> wrote:
> Dear members,
> Is it possible to iterate arrays ? Loops will definitely solve this, but i
> don't know how to do it in puppet.
> waiting for suggestions and comments
unluckily there is no direct loop to do this, puppets array (and hash)
handling is rather rudimentary.
but you can work on elemts of an array by using a define:
if you have an array like:
$array=[ "entry1", "entry2" ]
you can use it like:
define dosomething {
# you will have your array element available here as $name
....
}
# use the define with your array
dosomething { $array }
Hope this helps a bit. But I would like to see a way to hande arrays
and hashes a bit more comfotable.
Bye
Frederik
>
> Thanks
>
> --
> M. Haris
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
On 18/02/10 11:14 PM, Frederik Wagner wrote:
> unluckily there is no direct loop to do this, puppets array (and hash)
> handling is rather rudimentary.
A hash construct will probably be present in the next major release
of Puppet: Rowlf.
Regards
James Turnbull
- --
Author of:
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Pulling Strings with Puppet (http://tinyurl.com/pupbook)
* Pro Nagios 2.0 (http://tinyurl.com/pronagios)
* Hardening Linux (http://tinyurl.com/hardeninglinux)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEVAwUBS30vlCFa/lDkFHAyAQLP6AgAhXu2bmsrJq6y7BS+cyyBElpjOQr8nnQa
2NtPpCjtsl+Se/g1mARMe+1AAZJ38f7bQIBzMqrnSwV/sO8J9JE846fw1PJ0AUPi
c/AkOnZvH80w8POHDirR/j2dQmTHGUSRHFXN3Uf/GMf20hSE49I4MonDBneYJ4O3
qwd/1v0YPKF+89ISzS6O4q7DMJDFrc0NB43IthBZ3aPY8A7uPjOLTKArNfaA+zfn
6xNb1luT1PUYV5NeeYT1Z9IKEh9Fz6vJtJBXqz/fjl9rGslAlTYmtNSxAcxvXWIZ
x2HIXeelhHoikB0z64BsZx7CzF6ZHi4aFPDcVeo4zkucOgLg4Lj+6g==
=OCMC
-----END PGP SIGNATURE-----
besides that, it might be also worth to think about what you like to
do. There have been several threads about this topic in the past on
this list and while examining the actual problem one tried to solve,
the actual solution was nearly always to solve the problem in a
different and better way.
Remember puppet is a declarative langauge, which is order independent
unless you specify one. It is the intend of the puppet language, well
this fits in general for external DSLs, to only have a specific set of
instruction to address the domain it was invented for.
So far I missed looping only a few times and in general if I
re-thought the actual problem I tried to solve, I came up with a
cleaner solution without looping.
So if you don't see any other solution than loops you could outline
your problem and somebody might be able to help you.
cheers pete
generally I agree, but I was thinking a long time to get a way of
dealing with a specific problem:
I pass (via a YAML configuration) an array parameter with
interface/network configurations to a network configuration class.
The parameters looks like:
$ifcfgs = [ eth0#00:11:22:33:44:55#1234:1234::1/64,10.20.30.40/24##,
eth1#00:11:22:33:44:55#11.22.33.44/24##]
From this I want to generate the ifcfg-eth0/1 files. Here a loop would
be really handy (and hash handling too, to make it more readable).
The only solution I found, was to extract the interfaces with the
regsubst-function as an array, calling a define where I extract the
relevant configuration element from the $ifcfgs via an inline_template
(in the end calling another define...).
As far as I understand it's still declarative, but very complicated
for a simple problem.
Bye
Frederik
>
> Remember puppet is a declarative langauge, which is order independent unless
> you specify one. It is the intend of the puppet language, well this fits in
> general for external DSLs, to only have a specific set of instruction to
> address the domain it was invented for.
>
> So far I missed looping only a few times and in general if I re-thought the
> actual problem I tried to solve, I came up with a cleaner solution without
> looping.
>
> So if you don't see any other solution than loops you could outline your
> problem and somebody might be able to help you.
>
> cheers pete
>