On Sat, Aug 11, 2012 at 5:21 AM, Stefan Schulte <[email protected]> wrote: > On Fri, Aug 10, 2012 at 05:10:20PM -0700, Douglas Garstang wrote: >> How can I pass an array to a define? It's not documented in the puppet >> language guide. >> >> I've got: >> >> define lvm::create_vg ( $pvdisks ) { >> exec { >> 'pvcreate': >> command => "/sbin/pvcreate -yf $pvdisks", >> unless => "/sbin/pvdisplay $pvdisks", >> ... >> } >> } >> >> class someclass { >> lvm::create_vg { >> 'bcvg01': >> pvdisks => ['/dev/xvdb1', '/dev/xvdc1']; >> } >> } >> >> Inside the define, $pvdisks gets expanded to '/dev/xvdb1/dev/xvdc1' >> >> Doug. > > Inside your define $pvdisks is whatever you passed as the pvdisks > parameter, so in your case $pvdisks *is* an array. But in the unless > parameter you use the array in a string context so all your items are > concatenated. Unfortunately puppet does not have a join function to > convert an array to a string. > > On the other hand it may not be desired to destroy every disk you pass > as in the pvdisks array if only one of the disks is not a LVM disk (as > pvdisplay returns with a non-zero exitcode as soon as one disk is not > recognized to be a LVM disk) > > So the best approach is probably to get the LVM puppet plugin and > replace your exec with > > physical_volume { $pvdisks: > ensure => present, > } > > The physical_volume is a new type that comes with the LVM plugin. > > [1] http://forge.puppetlabs.com/puppetlabs/lvm
Thanks. What am I looking at when I extract this? I was expecting to see a couple of .pp files. Installation documentation!? Doug. -- 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.
