Closed moserke closed 10 years ago
Shell provisioner didn't work for us on the 0.1.2 vagrant-windows hence the monkey patch. However, for the new version shell seems to be working again, so solved this by adding a new shell provisioner before chef like such:
config.vm.provision :shell do |shell|
shell.inline = <<-EOS
if ((hostname) -ne "#{config.vm.host_name}") {
shutdown /s /t 0 /f;
Write-Host "Reboot required, shutting down, 'vagrant up' to restart! (Can take a moment, be patient!)"
exit 1
}
EOS
end
I think you're solution with the shell provisioner probably makes the most sense, at least for now. It would be nice if the plugin handled the renaming all the way through with a reboot, but I'm hesitant to force it where the user has no control over it.
Yeah, I should have tried that first. vagrant-windows 0.1.2 shell provisioner didn't work with windows 2012 so had to go down the monkey patch path. Had forgotten to try the shell provisioner again.
For most folks (not domain joining) just renaming the box and not rebooting probably works just fine. Managing the rename through a whole reboot sounds like the best approach, but don't know if that's possible with how vagrant would deal with things?
Renaming the host should force a reboot to make the rename take effect. This is extra important if you are domain joining your vagrant box.
We solved this in vagrant-windows 0.1.2 by doing the following in our vagrant files to monkey patch things:
However things seem to be late loaded in the new plugin world and can't seem to find a hook in the Vagrantfile when the VagrantWindows::Guest::Cap::ChangeHostName class is loaded so that it can be Monkey patched with the above second execute.
Is there a good place to do this in the Vagrantfile or a way to set this behavior on the plugin directly?