Unverified Commit d3cf867d authored by Stefan Scherer's avatar Stefan Scherer
Browse files

Shutdown windows_2016 with sysprep

parent e88c9a83
...@@ -12,4 +12,19 @@ Replace it with ...@@ -12,4 +12,19 @@ Replace it with
"shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml", "shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml",
``` ```
and on the first `vagrant up` the box will boot with an out-of-box-experience (OOBE) Also make sure to add the `./scripts/unattend.xml` file to the `floppy_files`.
On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE)
## Windows Server 2016
On newer systems like Windows 10 and Windows Server 2016 this shutdown_command is not enough.
We also have to stop the "tiledatamodelsvc" service to make sysprep work. So we use a small cmd script.
```json
"shutdown_command": "a:/sysprep.bat"
```
Also make sure to add the files `./scripts/unattend.xml` and `./scripts/sysprep.bat` to the `floppy_files`.
On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE)
net stop tiledatamodelsvc
c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /shutdown /unattend:a:\unattend.xml
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</settings> </settings>
<settings pass="specialize"> <settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>vagrant-2012</ComputerName> <ComputerName>vagrant</ComputerName>
<CopyProfile>false</CopyProfile> <CopyProfile>false</CopyProfile>
</component> </component>
</settings> </settings>
......
...@@ -11,25 +11,27 @@ ...@@ -11,25 +11,27 @@
"iso_checksum": "{{user `iso_checksum`}}", "iso_checksum": "{{user `iso_checksum`}}",
"floppy_files": [ "floppy_files": [
"{{user `autounattend`}}", "{{user `autounattend`}}",
"./floppy/WindowsPowershell.lnk",
"./floppy/PinTo10.exe",
"./scripts/disable-screensaver.ps1", "./scripts/disable-screensaver.ps1",
"./scripts/disable-winrm.ps1", "./scripts/disable-winrm.ps1",
"./scripts/enable-winrm.ps1", "./scripts/enable-winrm.ps1",
"./scripts/microsoft-updates.bat", "./scripts/microsoft-updates.bat",
"./scripts/unattend.xml",
"./scripts/sysprep.bat",
"./scripts/win-updates.ps1" "./scripts/win-updates.ps1"
], ],
"communicator":"winrm", "communicator":"winrm",
"winrm_username": "vagrant", "winrm_username": "vagrant",
"winrm_password": "vagrant", "winrm_password": "vagrant",
"winrm_timeout" : "4h", "winrm_timeout" : "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "shutdown_command": "a:/sysprep.bat",
"ram_size": 2048, "ram_size": 2048,
"cpu": 2, "cpu": 2,
"switch_name":"{{user `hyperv_switchname`}}", "switch_name":"{{user `hyperv_switchname`}}",
"enable_secure_boot":true "enable_secure_boot":true,
"enable_virtualization_extensions":true
}, },
{ {
"vm_name":"WindowsServer2016",
"type": "vmware-iso", "type": "vmware-iso",
"communicator": "winrm", "communicator": "winrm",
"iso_url": "{{user `iso_url`}}", "iso_url": "{{user `iso_url`}}",
...@@ -39,8 +41,8 @@ ...@@ -39,8 +41,8 @@
"boot_wait": "2m", "boot_wait": "2m",
"winrm_username": "vagrant", "winrm_username": "vagrant",
"winrm_password": "vagrant", "winrm_password": "vagrant",
"winrm_timeout": "6h", "winrm_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "shutdown_command": "a:/sysprep.bat",
"guest_os_type": "windows9srv-64", "guest_os_type": "windows9srv-64",
"disk_size": 61440, "disk_size": 61440,
"vnc_port_min": 5900, "vnc_port_min": 5900,
...@@ -48,12 +50,12 @@ ...@@ -48,12 +50,12 @@
"version": 11, "version": 11,
"floppy_files": [ "floppy_files": [
"{{user `autounattend`}}", "{{user `autounattend`}}",
"./floppy/WindowsPowershell.lnk",
"./floppy/PinTo10.exe",
"./scripts/disable-screensaver.ps1", "./scripts/disable-screensaver.ps1",
"./scripts/disable-winrm.ps1", "./scripts/disable-winrm.ps1",
"./scripts/enable-winrm.ps1", "./scripts/enable-winrm.ps1",
"./scripts/microsoft-updates.bat", "./scripts/microsoft-updates.bat",
"./scripts/unattend.xml",
"./scripts/sysprep.bat",
"./scripts/win-updates.ps1" "./scripts/win-updates.ps1"
], ],
"vmx_data": { "vmx_data": {
...@@ -65,6 +67,7 @@ ...@@ -65,6 +67,7 @@
} }
}, },
{ {
"vm_name":"WindowsServer2016",
"type": "virtualbox-iso", "type": "virtualbox-iso",
"communicator": "winrm", "communicator": "winrm",
"iso_url": "{{user `iso_url`}}", "iso_url": "{{user `iso_url`}}",
...@@ -74,20 +77,20 @@ ...@@ -74,20 +77,20 @@
"boot_wait": "2m", "boot_wait": "2m",
"winrm_username": "vagrant", "winrm_username": "vagrant",
"winrm_password": "vagrant", "winrm_password": "vagrant",
"winrm_timeout": "6h", "winrm_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "shutdown_command": "a:/sysprep.bat",
"guest_os_type": "Windows2012_64", "guest_os_type": "Windows2012_64",
"guest_additions_mode": "disable", "guest_additions_mode": "disable",
"disk_size": 61440, "disk_size": 61440,
"floppy_files": [ "floppy_files": [
"{{user `autounattend`}}", "{{user `autounattend`}}",
"./floppy/WindowsPowershell.lnk",
"./floppy/PinTo10.exe",
"./scripts/disable-screensaver.ps1", "./scripts/disable-screensaver.ps1",
"./scripts/disable-winrm.ps1", "./scripts/disable-winrm.ps1",
"./scripts/enable-winrm.ps1", "./scripts/enable-winrm.ps1",
"./scripts/microsoft-updates.bat", "./scripts/microsoft-updates.bat",
"./scripts/win-updates.ps1", "./scripts/win-updates.ps1",
"./scripts/unattend.xml",
"./scripts/sysprep.bat",
"./scripts/oracle-cert.cer" "./scripts/oracle-cert.cer"
], ],
"vboxmanage": [ "vboxmanage": [
...@@ -128,7 +131,6 @@ ...@@ -128,7 +131,6 @@
"type": "windows-shell", "type": "windows-shell",
"execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
"scripts": [ "scripts": [
"./scripts/pin-powershell.bat",
"./scripts/set-winrm-automatic.bat", "./scripts/set-winrm-automatic.bat",
"./scripts/compile-dotnet-assemblies.bat", "./scripts/compile-dotnet-assemblies.bat",
"./scripts/uac-enable.bat", "./scripts/uac-enable.bat",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment