define virtual::kvm::kvmx::instance( $vg, $size, $ram, $shell, $udev = false, ) { virtual::kvm::instance { $name: udev => $udev, shell => $shell ? { undef => '/usr/local/bin/kvmx-restricted-shell', default => $shell, }, } exec { "kvmx-lvcreate-${name}": command => "/sbin/lvcreate --name ${name} --size ${size} ${vg}", user => root, creates => "/dev/${vg}/${name}", #onlyif => "test ! -e /dev/${vg}/${name}" } exec { "kvmx-init-${name}": command => "/usr/local/bin/kvmx init", user => $name, environment => [ "HOME=/home/${name}" ], cwd => "/home/${name}/vms/${name}", creates => "/home/${name}/vms/${name}/kvmxfile", require => Virtual::Kvm::Instance["$name"], } virtual::kvm::kvmx::config { "${name}-memory": vm => $name, param => 'memory', value => $ram, } virtual::kvm::kvmx::config { "${name}-size": vm => $name, param => 'size', value => $size, } }