On Sat, Aug 11, 2012 at 01:46:57PM -0700, James A. Peltier wrote:
> ----- Original Message -----
> | 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
> | 
> | -Stefan
> 
> Great!  But what happens if you want to specify multiple physical volumes be 
> a member of a single data volume during creation.  Is the expectation that 
> you'd always specify a lvm:vg with the initial disk and then lvm:vg extend 
> that volume?

Do you mean something like sda1 and sda2 beeing two physical volumes in
the volume group vg? This should work:


    physical_volume { [ '/dev/sda1', '/dev/sda2']:
      ensure => present.
    }

    volume_group { 'vg':
      ensure           => present,
      physical_volumes => [ '/dev/sda1', '/dev/sda2' ],
      require          => [
        Physical_volume['/dev/sda1'],
        Physical_volume['/dev/sda2'],
      ],
    }

-Stefan

-- 
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.

Reply via email to