Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sysprep sometimes not finished #194

Open
sofam opened this issue Mar 9, 2020 · 1 comment
Open

Sysprep sometimes not finished #194

sofam opened this issue Mar 9, 2020 · 1 comment
Assignees

Comments

@sofam
Copy link

sofam commented Mar 9, 2020

We have noticed lately that some builds with Packer are botched. A rebuild of the exact same .json works.

After some digging into the failed instances (over the SAC on Windows on GCP) we noticed that they weren't sysprepped correctly.

PS C:\Windows\Setup\State> ls                                                  
                                                                               
                                                                                
    Directory: C:\Windows\Setup\State                                           
                                                                               
                                                                               
Mode                LastWriteTime         Length Name                          
----                -------------         ------ ----                          
-a----       05-03-2020     20:19             42 State.ini                     
PS C:\Windows\system32\sysprep> ls                                             
                                                                               
                                                                               
    Directory: C:\Windows\system32\sysprep                                     
              :1                                                               
              :1                                                               
Mode                LastWriteTime         Length Name                           
----                -------------         ------ ----                           
d-----       05-03-2020     17:08                ActionFiles                   
d-----       15-09-2018     11:05                en-US                         
d-----       12-02-2020     11:00                Panther                       
-a----       15-09-2018     09:09        1349120 sysprep.exe                   
-a----       05-03-2020     20:17              0 Sysprep_succeeded.tag         
                                     

The sysprep.ps1 script checks for the sysprep_succeeded.tag file, however the State.ini file is first updated with the correct state 2 minutes after the .tag file is written.

This means that the instance sometimes is shut down before it is finished sysprepping.
This documentation explains where to look for the state. You can either check for it in the registry, or in the State.ini file mentioned above.

For now, the workaround is running GCESysprep with the no_shutdown parameter, checking the registry with a loop like this

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 } }
@rofuentes
Copy link
Contributor

Thanks for reporting @sofam ! The code checking sysprep_succeeded.tag has been around a while, and most likely needs to be modified to check the registry key instead. We will release new images this week, and a new sysprep package (and associated files) the following week, assuming our tests pass.

@rofuentes rofuentes self-assigned this Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants