Module for VirtualBox

105 views
Skip to first unread message

Rolfs

unread,
Mar 31, 2009, 7:30:54 PM3/31/09
to Puppet Users
Hello!

I have searched around on google and github without finding any puppet
module for managing VirtualBox installations.

I've seen some modules for xen, but none that works out of the box on
ubuntu. For what I know, xen need a special build kernel or some
kernel modules.

Here is my start... any ideas or suggestions?


class virtualbox {

# Install
package { virtualbox-ose:
name => $operatingsystem ? {
default => "virtualbox-ose",
},
ensure => present,
}
package { virtualbox-ose-modules-generic:
name => $operatingsystem ? {
default => "virtualbox-ose-modules-generic",
},
ensure => present,
}
package { bridge-util:
name => $operatingsystem ? {
default => "bridge-utils",
},
ensure => present,
}

}
define createvm($name, $basefolder = '/vbox') {
# VBoxManage createvm -name $name -basefolder $basefolder
#
}

paul matthews

unread,
Apr 1, 2009, 5:11:09 AM4/1/09
to puppet...@googlegroups.com
That looks pretty good to me. I've been working on the same thing and your method looks a lot neater. The difficulty I've found, is the define statement for the vm itself which I've ended up separating as a separate module / class called vboxinstance.  It's still being worked on so it's not worth anyone relying on the following but I've included my workings as an idea:-

vboxinstance.pp

define vboxvm::vboxinstance (vboxif=$vboxif,vboxip=$vboxip,vboxname=$vboxname,vboxpath=$vboxpath,domain_name=$domain_name, dnsserver1=$dnsserver1,gateway=$gateway,netmask=$netmask,macaddress=$macaddress, memory=$memory, cpu_count=$cpu_count,  ) {

exec { "create-vboxvm":
    command => "VBoxManage -nologo createvm -name $vboxname -register -memory 512MB -vram 1 -accelerate3d off -acpi on -ioapic off -pae off -monitorcount 1  -biosbootmenu disabled -boot1 disk -boot2 net -cableconnected1 on -nic1 hostif -hostifdev1 $vboxname -macaddress1 $macaddress -vrdpport 3390",
    notify => Exec["create-vboxvdi"]
}

exec { "create-vboxvdi":
    command => "VBoxManage createvdi -filename $vboxname.vdi -size 6000 -register",
       notify => Exec["modify-vboxvm"]
}

exec { "modify-vboxvm":
    command => "VBoxManage modifyvm $vboxname -hda $vboxname.vdi",
      notify => Exec["start-vboxvm"]
}

exec { "start-vboxvm":
    command => "VBoxManage startvm $vboxname -type vrdp",
}

The plan is for the nodes.pp to contain the definition name as follows:-


  node 'vmhost.test.com' {
   virtualbox::vboxinstance { "vbox1":
     vboxif => "bnx0",
     vboxip => "10.0.89.95",
     vboxname => "vbox1",
     zonepath => "/zfs/vbox1",
     domain_name => "test.com",
     dnsserver1 => "10.0.136.11",
     netmask =>"255.255.255.0",
     gateway => "10.0.89.1",
   }
   virtualbox::vboxinstance { "vbox2":
     vboxif => "bnx0",
     ::       ::      ::
    etc
   }

Cheers
Paul


2009/4/1 Rolfs <goo...@krev.no>



--
Paul Matthews
----------------------------------------------------------------------

Rolfs

unread,
Apr 1, 2009, 4:54:05 PM4/1/09
to Puppet Users


paul matthews wrote:
> define vboxvm::vboxinstance
> (vboxif=$vboxif,vboxip=$vboxip,vboxname=$vboxname,vboxpath=$vboxpath,domain_name=$domain_name,
> dnsserver1=$dnsserver1,gateway=$gateway,netmask=$netmask,macaddress=$macaddress,
> memory=$memory, cpu_count=$cpu_count, ) {
>
> exec { "create-vboxvm":
> command => "VBoxManage -nologo createvm -name $vboxname -register
> -memory 512MB -vram 1 -accelerate3d off -acpi on -ioapic off -pae off
> -monitorcount 1 -biosbootmenu disabled -boot1 disk -boot2 net
> -cableconnected1 on -nic1 hostif -hostifdev1 $vboxname -macaddress1
> $macaddress -vrdpport 3390",
> notify => Exec["create-vboxvdi"]
> }

This is a good idea. I got some good ideas of your last post.

I've been thinking and trying this today. Maybe it is less complicated
to create a template file and install them as /etc/init.d/vbox-
$vbosname scripts pr virtual machine and let the init.d script
generate the virtual disk and create the vm if it does not exitst.
Just making puppet install the init.d-startup script and make sure it
runs on the right server.

Looks like we use the different VBoxManage parameter. I've tried the
one available from the ubuntu repo.
I think I need to use the non-free version of VirtualBox to enable the
"headless startup" as I understood if from this bugreport:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=475202

Regards
Rolf

Rolfs

unread,
Apr 2, 2009, 10:17:27 PM4/2/09
to Puppet Users

Presenting my first puppet module for virtualbox:
http://github.com/rolfs/puppet-virtualbox/tree/master

Regards
Rolf
Reply all
Reply to author
Forward
0 new messages