Did you ever find a better work around for this? I'm trying to do the same
thing (mainly to prevent collisions if I want to have 2 VMs up at the same
time).
My initial thought was to do the following:
config.vm.provider :virtualbox do |vb|
vb.customize ['createhd', '--filename', "#{:id}-drive2.vdi", '--size', 5
* 1024]
vb.customize ['storageattach', :id, '--storagectl', 'SCSI Controller',
'--port', 1, '--device', 0, '--type', 'hdd', '--medium',
"#{:id}-drive2.vdi']
end
Unfortunately, :id is being interpolated as "id" when this happens.
On Monday, September 16, 2013 2:36:35 PM UTC-4, Levon Becker wrote:
>
> This is my current workaround using an environment variable that works...
> but really would rather not depend on the user/developer to have to set
> this prior.
>
> # Configuration for Virtualbox provider
> config.vm.provider "virtualbox" do |vb|
> # Virtualbox Name
> vb.customize [ "modifyvm", :id, "--name", $suggested_hostname ]
> # Memory
> vb.customize [ "modifyvm", :id, "--memory", "1024" ]
> # Chipset (Supposedly better CPU performance)
> vb.customize [ "modifyvm", :id, "--chipset", "ich9" ]
> # NIC 1 (Better TCP over NAT performance, at least on Windows)
> vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
> vb.customize ["modifyvm", :id, "--natsettings1",
> "9000,1024,1024,1024,1024"]
> # NIC 2 (Host Only Access)
> vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
> vb.customize ["modifyvm", :id, "--hostonlyadapter2", "VirtualBox
> Host-Only Ethernet Adapter"]
> # Storage Controller
> # NOTE: name "SATA" for some images, "SATA Controller" for others
> #vb.customize ["storagectl", :id, "--name", "SATA", "--hostiocache",
> "on"]
>
> # Add Second Drive
> # This is a workaround until I find a better solution. You need to
> have an environment variable set to the
> # Virtualbox VM path. i.e. type %VBOX_USER_HOME%\VirtualBox.xml |
> findstr defaultMachineFolder
> # i.e. set VBOX_VM_PATH=C:\NoAVScans\Vbox_VMs
> if ENV["VBOX_VM_PATH"]
> disk2_path = ENV["VBOX_VM_PATH"] + "/" + $suggested_hostname + "/" +
> "box-disk2" + ".vmdk"
> else
> disk2_path = Dir.pwd() + "/" + "box-disk2" + ".vmdk"
> end
>
> vb.customize ["storagectl", :id, "--name", "SATA", "--sataportcount",
> 2, "--hostiocache", "on"]
> vb.customize ["createhd", "--filename", disk2_path, "--size", 30*1024,
> "--format", "vmdk"]
> vb.customize ["storageattach", :id, "--storagectl", "SATA", "--port",
> 1, "--device", 0, "--type", "hdd", "--medium", disk2_path]
> end
>
> On Monday, September 16, 2013 9:15:43 AM UTC-7, [email protected]:
>>
>> This seems like a simple task, but I've been chasing my tail on this for
>> long enough that I thought I'd reach out and see if someone can give me a
>> hand.
>>
>> ENVIRONMENT:
>> Vagrant 1.3.1 on Windows (I know.. I'm working on building a CentOS LXC
>> for Ubuntu Vagrant)
>> Virtualbox 4.2.18
>> Vagrantfile version 2
>>
>>
>> GOAL:
>> Add another (2nd) virtual disk to a box image. (I'll mount it with Chef
>> cookbook etc.)
>>
>>
>> Q: Is there a way to get the host path to a VM being provisioned in the
>> Vagrantfile. Meaning is there a variable with the full path or at least
>> root path and then I can append the suggested hostname?
>>
>>
>> I'd like to not have to use a system environment variable like I started
>> to code for...
>>
>>
>> EXAMPLE: (So far)
>> # Configuration for Virtualbox provider
>> config.vm.provider "virtualbox" do |vb|
>> # Memory
>> vb.customize [ "modifyvm", :id, "--memory", "1024" ]
>> # Chipset (Supposedly better CPU performance)
>> vb.customize [ "modifyvm", :id, "--chipset", "ich9" ]
>> # NIC 1 (Better TCP over NAT performance, at least on Windows)
>> vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
>> vb.customize ["modifyvm", :id, "--natsettings1",
>> "9000,1024,1024,1024,1024"]
>> # NIC 2 (Host Only Access)
>> vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
>> vb.customize ["modifyvm", :id, "--hostonlyadapter2", "VirtualBox
>> Host-Only Ethernet Adapter"]
>>
>> # Add Second Drive
>> if ENV["VBOX_VM_PATH"]
>> disk2_path = ENV["VBOX_VM_PATH"] + :vm + "/" + "box-disk2" + ".vmdk"
>> else
>> disk2_path = Dir.pwd() + "/" + "box-disk2" + ".vmdk"
>> end
>>
>> vb.customize ["storagectl", :id, "--name", "SATA", "--sataportcount",
>> 2, "--hostiocache", "on"]
>> vb.customize ["createhd", "--filename", disk2_path, "--size",
>> 30*1024, "--format", "vmdk"]
>> vb.customize ["storageattach", :id, "--storagectl", "SATA",
>> "--port", 1, "--device", 0, "--type", "hdd", "--medium", disk2_path]
>> end
>>
>> Thanks!
>>
>
--
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.