About | FAQ | Help
Ask Your Question

puppet allow empty or null variables?

asked 2013-08-14 14:05:46 -0500

Luke gravatar image


I am using the puppetlabs/lvm module in an attempt to automatically provision lvm storage after it is assigned in my cloud instances. Thing is I am having problems with having is that I don't necessarily know how many variables it is going to give. It can assign 1 - 10 storage volumes.

Basically I am going to pass provisioning info using the aws PHP sdk so that puppet can query it using a custom fact e.g.

Facter::Util::Resolution.exec('/usr/bin/curl | cut -d , -f2') could pull out the ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-08-15 13:20:13 -0500

Luke gravatar image

updated 2013-08-22 14:43:04 -0500


If I pull the head from puppetlabs-lvm this won't work:

    physical_volume { "volumes1":
    name => ['/dev/xvdf', '/dev/xvdg'],
    ensure => present
     volume_group { "vg01":
            ensure => present,
            physical_volumes => ['/dev/xvdf', '/dev/xvdg'],
     logical_volume { "lv01":
            ensure => present,
            volume_group => "vg01",
            size => "15G"
    filesystem { "/dev/vg01/lv01":
            ensure => present,
            fs_type => "ext4",

nor this

lvm::volume { 'lv01':
            ensure => present,
            vg => 'vg01',
            pv => ['/dev/xvdf', '/dev/xvdg'],
            fstype => 'ext4',
            size => '15G',

However when I did a git clone of your multiple_pvs branch from https://github.com/huit/puppetlabs-lvm it works great (I was using the second sample).

Thank you for your help. Not sure if your changes ... (more)

edit flag offensive delete link more


Cool, yeah I got mixed up in which branch was where. I wasn't the original author, but I'm working on cleaning up my branch and trying another PR.

ramindk gravatar imageramindk ( 2013-08-15 13:32:31 -0500 )edit

answered 2013-08-14 15:26:36 -0500

ramindk gravatar image

I'd let your custom fact return a string which might look like this.

my_devices => xvdb,xvdc,xvdd,xvde

Then use the split function to turn it into an array and pass it in directly.

$a_devices = split($my_devices, ',')

volume_group { 'vg01':
  ensure           => present,
  physical_volumes => [ $a_devices ],

logical_volume { 'lv01':
  ensure       => present,
  volume_group => 'vg01',
  size         => '15G',

filesystem { '/dev/vg01/lv01':
  ensure  => present,
  fs_type => 'ext4',
edit flag offensive delete link more


Hi, I was thinking something like this but my problem is that volume_group can take multiple physical volumes but it requires the actually physical_volume { $dev1: ensure => present } before it works ...(more)

Luke gravatar imageLuke ( 2013-08-15 07:43:35 -0500 )edit

So basically my predicament is that physical_volume resource needs one variable but can be defined multiple times while volume_group needs multiple of the same variables but will only be defined once.

Luke gravatar imageLuke ( 2013-08-15 07:45:03 -0500 )edit

edit: You might want to pull from puppetlabs-lvm head on github. It has a couple of fixes and has added support for using an array to feed physical_volume. https://github.com/puppetlabs/puppetlabs-lvm

ramindk gravatar imageramindk ( 2013-08-15 10:26:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-08-14 14:05:46 -0500

Seen: 642 times

Last updated: Aug 22 '13