joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Add Option To Sysprep As Shutdown Command #25

Open joefitzgerald opened 10 years ago

joefitzgerald commented 10 years ago

This would ensure that a base box does not begin counting down the activation clock until you use it for the first time - at the expense of using up one of the three sysprep /generalize runs that you can do (http://technet.microsoft.com/en-us/library/dd744512(v=ws.10).aspx).

StefanScherer commented 10 years ago

Could this sysprep be used to prepare the basebox in a way to rename the computername after the next boot which is then done by first vagrant up call?

I think of a way

  1. packer shuts Down the basebox with sysprep
  2. Add basebox to vagrant
  3. vagrant up with hostname setting in Vagrantfile
  4. vagrant and propably the vagrant-windows plugin sets the hostname and the new created box has the computername without the need of another reboot?

I don't know sysprep enough, but I have seen manually created VMs which ask for a new computername on first boot. If this could be set with something like an unattend.xml on boot time by vagrant then this could save me one reboot.

At the moment I have to reboot freshly created vagrant Windows boxes so they really have their new computernames from vagrant-windows plugin.

sneal commented 10 years ago

My Packer shutdown command specifies another unattend xml file - which contains the new computer name. This is run on first boot after Packer has finished with the box.

"shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml",

ghost commented 10 years ago

Can you please post your unattend.xml I do not seem to be able to change the computername as it errors out.

kensykora commented 10 years ago

+1 to this idea, I'll look into it, but like others I don't have much experience with sysprep. @sneal could you post your unattend.xml file for this? Any thoughts on how to pass the hostname to sysprep through an environment variable or something along those lines?

stonith commented 10 years ago

I've been using this one for 2008R2: https://gist.github.com/stonith/33a75407b465cfbf4f5e

Specify the ComputerName on line 39. I'm also uninstalling OpenSSH on first boot but that can be removed.

lilo6723 commented 7 years ago

Anyone still working on this ?