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
--
Paul Matthews
----------------------------------------------------------------------