Hi,
I am new to Vagrant. I wanted to mount the an existing virtual disk as a second disk using Virtual box provider. I have tried with the following code but nothing got attached. So how do I attach an existing virtual disk using Vbox provider? Does ‘createhd’ is mandatory before ‘storageattach’ or have I missed something?
shared_disk = "SharedData/data.vmdk"
Vagrant.configure("2") do |config|
config.vm.box = 'vsphere.box'
config.vm.box_url = './vsphere.box'
config.vm.guest = 'windows'
config.vm.boot_timeout = 10800
config.vm.network "private_network", ip: settings_vm['ip_address'], netmask: "255.255.254.0"
# Make Vagrant use WinRM for remote scripting
config.vm.communicator = 'winrm'
config.winrm.username = settings_secrets['win-user']
config.winrm.password = settings_secrets['win-pass']
config.winrm.timeout = 10800 # 3 hours
config.winrm.retry_delay = 60 # seconds
config.winrm.max_retries = 60 #60 minutes in total
config.winrm.execution_time_limit = 10800 # 3 hours
config.vm.provision :"file", :source => "~/tools/windows", :destination => settings_recipe['additional_software_path']
# Disable synced folder for now - rsync has issues working with sudo_command
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.provider :vsphere do |vsphere|
vsphere.host = settings_global['vsphere_host']
vsphere.user = settings_secrets['vsphere-user']
vsphere.password = settings_secrets['vsphere-pass']
vsphere.insecure = true
vsphere.wait_for_sysprep = true
vsphere.ip_address_timeout = 7200
vsphere.cpu_count = settings_vm['cpu_count']
vsphere.memory_mb = settings_vm['memory_mb']
vsphere.template_name = settings_vm['template']
vsphere.vm_base_path = 'GPD/Core'
vsphere.data_store_name = 'mydata:datastore2'
vsphere.name = settings_vm['vm_name']
vsphere.customization_spec_name = 'vagrant-windows'
vsphere.vlan = 'dvPG_Vlan_111_Qa_Server_Vlan'
end
# attach storage devices
config.vm.provider :virtualbox do |vbox|
vbox.customize ['storageattach', :id, '--storagectl', 'mydata:datastore2', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', shared_disk]
end
end