hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.16k stars 4.43k forks source link

Enhancement Request: Allow a user-customizable delay before rebooting after hostname change #12542

Open clong opened 2 years ago

clong commented 2 years ago

Is your feature request related to a problem? Please describe. After a Windows VM has booted after being sysprepped, some additional configuration starts occurring when vagrant logs in to configure the hostname. For example, the VMware Tools installer will run to re-configure itself:

image

However, if the machine reboots before the installation completes, it will fail to install successfully. This leads to a race condition where the installer is trying to finish completing before the reboot occurs.

Describe the solution you'd like It would be great to allow a custom /t flag in shutdown_script defined in https://github.com/hashicorp/vagrant/blob/2eb4406e2ea0bfb562fd9d608c075d74e175c647/plugins/guests/windows/cap/reboot.rb#L12

This flag would be exposed as a config.vm variable.

Describe alternatives you've considered If VMware tools fail to install, shared folders will fail to enable and vagrant up will fail. I've tried disabling folder syncing, forcing a vmware tools install, then enabling folder syncing but that doesn't appear to be a viable path.

Additional context Source of issue discovery: https://github.com/clong/DetectionLab/issues/720

pklx01 commented 1 year ago

I did some quick testing. The reboot was occurring due to changing the hostname in the vm.hostname var

cfg.vm.hostname = "win10"

If you remove this, it will halt the reboot and allow the vmware tools to execute and move onto the provisioning scripts