----- 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?
--
James A. Peltier
Manager, IT Services - Research Computing Group
Simon Fraser University - Burnaby Campus
Phone : 778-782-6573
Fax : 778-782-3045
E-Mail : [email protected]
Website : http://www.sfu.ca/itservices
http://blogs.sfu.ca/people/jpeltier
Success is to be measured not so much by the position that one has reached
in life but as by the obstacles they have overcome. - Booker T. Washington
--
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.