Created
March 24, 2020 19:22
-
-
Save riezebosch/207d71bed0a61dfe56d6acb59c4424ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"vm_size": "Standard_DS13_v2", | |
}, | |
"builders": [ | |
{ | |
"name": "azure-arm", | |
"type": "azure-arm", | |
"client_id": "{{user `client_id`}}", | |
"client_secret": "{{user `client_secret`}}", | |
"subscription_id": "{{user `subscription_id`}}", | |
"object_id": "{{user `object_id`}}", | |
"vm_size": "{{user `vm_size`}}", | |
"build_resource_group_name": "{{user `resource_group`}}", | |
"managed_image_resource_group_name": "{{user `resource_group`}}", | |
"managed_image_name": "{{user `managed_image_name`}}", | |
"custom_managed_image_name": "{{user `custom_managed_image_name`}}", | |
"custom_managed_image_resource_group_name": "{{user `custom_managed_image_resource_group`}}", | |
"managed_image_zone_resilient": true, | |
"os_type": "Windows", | |
"communicator": "winrm", | |
"winrm_use_ssl": "true", | |
"winrm_insecure": "true", | |
"winrm_timeout": "20m", | |
"winrm_username": "packer", | |
"async_resourcegroup_delete": "true" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "powershell", | |
"scripts": [ | |
"{{ template_dir }}/Install-Chocolatey.ps1" | |
] | |
}, | |
{ | |
"type": "windows-restart", | |
"restart_timeout": "30m" | |
}, | |
{ | |
"type": "powershell", | |
"inline": [ | |
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}", | |
"& $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 } }" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment