Updated docs with more robust sysprep script for the windows Azure builder

This commit is contained in:
Oscar Elfving 2017-09-26 11:52:10 +02:00
parent 875cccfb44
commit 8173e5d3ce
1 changed files with 18 additions and 0 deletions

View File

@ -216,6 +216,24 @@ The following provisioner snippet shows how to sysprep a Windows VM. Deprovision
}
```
In some circumstances the above isn't enough to reliably know that the sysprep is actually finished generalizing the image, the code below will wait for sysprep to write the image status in the registry and will exit after that. The possible states, in case you want to wait for another state, [are documented here](https://technet.microsoft.com/en-us/library/hh824815.aspx)
``` json
{
"provisioners": [
{
"type": "powershell",
"inline": [
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }"
]
}
]
}
```
### Linux
The following provisioner snippet shows how to deprovision a Linux VM. Deprovision should be the last operation executed by a build.