Open mikolajpiecuch opened 1 month ago
@mikolajpiecuch I cannot recall any explicit changes around the DVD drives.
Can you share maybe Vagrantfiles of working and not working configs? Then I can take a more detailed look and try to reproduce it.
The following line throws an erorr (to resize primary disk):
base.vm.disk :disk, size: "200GB", primary: true
Full Vagrantfile with error caused by 'DVD Drive' attached to ControllerLocation=0:
Vagrant.configure("2") do |config|
config.vm.define "base" do |base|
base.vm.box = "gusztavvargadr/windows-server"
base.vm.disk :disk, size: "200GB", primary: true
end
end
'DVD Drive' connected to Location 0:
Stacktrace from vagrant:
C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/cap/configure_disks.rb:63:in `get_current_disk': undefined method `[]' for nil:NilClass (NoMethodError)
current_disk = machine.provider.driver.get_disk(current_disk["Path"])
^^^^^^^^
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/cap/configure_disks.rb:83:in `handle_configure_disk'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/cap/configure_disks.rb:29:in `block in configure_disks'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/cap/configure_disks.rb:27:in `each'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/cap/configure_disks.rb:27:in `configure_disks'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/capability_host.rb:114:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/capability_host.rb:114:in `capability'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/disk.rb:23:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/cleanup_disks.rb:33:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/net_set_mac.rb:18:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/net_set_vlan.rb:18:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/set_name.rb:41:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/configure.rb:111:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/provision.rb:83:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builder.rb:183:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `block in run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/util/busy.rb:22:in `busy'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/call.rb:56:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builder.rb:183:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `block in run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/util/busy.rb:22:in `busy'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/call.rb:56:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builder.rb:183:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `block in run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/util/busy.rb:22:in `busy'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/call.rb:56:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/import.rb:81:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builder.rb:183:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `block in run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/util/busy.rb:22:in `busy'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/call.rb:56:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/config_validate.rb:28:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builtin/handle_box.rb:59:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/check_access.rb:22:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/providers/hyperv/action/check_enabled.rb:21:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/warden.rb:38:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/builder.rb:183:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `block in run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/util/busy.rb:22:in `busy'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/action/runner.rb:104:in `run'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/machine.rb:247:in `action_raw'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/machine.rb:216:in `block in action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:649:in `lock'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/machine.rb:202:in `call'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/machine.rb:202:in `action'
from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/batch_action.rb:89:in `block (2 levels) in run'
from C:/Program Files/Vagrant/embedded/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
As a temporary workaround I manually removed 'DVD Drive' from my base image after provisioning.
@mikolajpiecuch thanks a lot for the details, will take a look and get back to you.
@mikolajpiecuch ok, I have found an issue and have a manual workaround.
The problem is with how Vagrant loads the the box. In certain cases it ignores the vmcx
file from the box - which does not contain any DVD drives -, and uses a static box.xml
, which indeed creates a DVD file and sets also for example network boot to be primary.
The workaround is to look up the box folder in your profile under .vagrant.d\boxes
and search for and remove the box.xml
files for the relevant boxes. For the latest windows-server
box the exact path is this:
~\.vagrant.d\boxes\gusztavvargadr-VAGRANTSLASH-windows-server\2102.0.2409\amd64\hyperv\Virtual Machines\box.xml
After deleting this file Vagrant will explicitly load the vmcx
file from the box and the resize operation will succeed for every new machine created, so this has to be done only once per box version, not per every machine.
The reason why it might work for other versions is that this load order depends on the ID of the exported machine which is non-deterministic and changes from release to release. I will try to update my build and remove this file box.xml
file explicitly for upcoming versions.
For more details please see https://github.com/hashicorp/packer-plugin-vagrant/issues/23.
Please let me know if this solves the issue.
@gusztavvargadr it works :) thank you very much for your support. I'm going to implement this workaround on my pipelines. Please let me know when you manage to remove box.xml from your images
Hi, I'm experiencing a problem with resizing disk created from "gusztavvargadr/windows-server" image using HyperV. I found that vagrant to resize (or just manipulate) primary disk, looks for disk attached to "ControllerLocation"=0 "ControllerNumber"= 0 (vagrant\plugins\providers\hyperv\cap\configure_disks.rb:56).
Log:
Unfortunately, VMs created from above image has also 'DVD Drive' which is attached to "ControllerLocation"=0 "ControllerNumber"= 0 and primary disk to "ControllerLocation"=1 "ControllerNumber"= 0. Earlier image (I'm not sure the date of the image) has only one primary disk attached to controller.
Has something changed recently with attaching (or not removing) 'DVD Drive'?