I am running Vagrant 2.3.7 on Windows 11. I have run into an issue where prior to the box booting, I need to run a command to “upgrade” the VM version. The command I need to run is “Update-VMVersion -VMName ”. I was looking at triggers and/or hooks, but I’m not able to find one that will trigger at the right spot. Here is the output when booting a box:
PS D:\Users\work\documents\repos\cs_lab> vagrant up sql --provider hyperv
Bringing machine 'sql' up with 'hyperv' provider...
==> sql: Verifying Hyper-V is enabled...
==> sql: Verifying Hyper-V is accessible...
==> sql: Importing a Hyper-V instance
sql: Creating and registering the VM...
sql: Successfully imported VM
==> sql: Using hostname "sql" as node name for Chef...
==> sql: Using hostname "sql" as node name for Chef...
sql: Configuring the VM...
sql: Setting VM Integration Services
==> sql: guest_service_interface is enabled
==> sql: heartbeat is enabled
==> sql: key_value_pair_exchange is enabled
==> sql: shutdown is enabled
==> sql: time_synchronization is enabled
==> sql: vss is enabled
sql: Setting VM Enhanced session transport type to disabled/default (VMBus)
==> sql: Starting the machine...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: start_vm.ps1
Error:
Failed to start VM 'cs_lab_sql_1694196240903_85757' failed to start.
'cs_lab_sql_1694196240903_85757' could not initialize.
The virtual machine could not be started because of a configuration error.
'cs_lab_sql_1694196240903_85757' failed to start. (Virtual machine ID 218F499E-11EE-4F46-A809-99AFE34B0660)
'cs_lab_sql_1694196240903_85757' failed to start worker process: Unspecified error (0x80004005). (Virtual machine ID 218F499E-11EE-4F46-A809-99AFE34B0660)
'cs_lab_sql_1694196240903_85757' could not initialize. (Virtual machine ID 218F499E-11EE-4F46-A809-99AFE34B0660)
The virtual machine could not be started because of a configuration error. Disable nested virtualization (stop exposing virtualization extensions to the virtual machine), or upgrade the virtual machine version.
If I run the command Update-VMVersion -VM (Get-VM cs_lab_sql_1694196240903_85757)
, then run my vagrant up
again, it will boot just fine. Somewhere between the Successfully imported VM
and Starting the machine...
I need to run this command. Is there a way to accomplish this via the Vagrantfile?
The intent with this is to distribute the Vagrantfile and associated cookbooks to colleagues for training, so if I can make this as automatic as possible, that would be appreciated.