Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Packer Template Windows Updates
{
"builders": [
{
"capture_container_name": "vsts-buildimagetask",
"capture_name_prefix": "{{user `capture_name_prefix`}}",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"communicator": "winrm",
"image_offer": "{{user `image_offer`}}",
"image_publisher": "{{user `image_publisher`}}",
"image_sku": "{{user `image_sku`}}",
"location": "{{user `location`}}",
"object_id": "{{user `object_id`}}",
"os_type": "Windows",
"resource_group_name": "dsncontrol-{{user `environment`}}-RG",
"storage_account": "dsncontrol{{user `environment` | lower}}",
"subscription_id": "{{user `subscription_id`}}",
"tenant_id": "{{user `tenant_id`}}",
"type": "azure-arm",
"vm_size": "Standard_D3_v2",
"winrm_insecure": "true",
"winrm_timeout": "15m",
"winrm_use_ssl": "true",
"winrm_username": "packer"
}
],
"post-processors": [],
"provisioners": [
{
"type": "windows-shell",
"inline": [
"cmd /c \"if exist c:\\\\DeployTemp rd /s /q c:\\\\DeployTemp\"",
"cmd /c \"mkdir c:\\\\DeployTemp\""
]
},
{
"type": "windows-update"
},
{
"type": "file",
"source": "{{user `package_path`}}",
"destination": "c:\\DeployTemp"
},
{
"type": "powershell",
"inline": [
"cd \"C:\\DeployTemp\"",
"C:\\DeployTemp\\{{user `script_imageconfig_path`}}"
]
},
{
"type": "file",
"source": "C:\\DeployTemp\\TestResults.xml",
"destination": "{{user `defaultdir`}}\\TestResults.xml",
"direction": "download"
},
{
"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 /quit /quiet"
]
}
],
"variables": {
"capture_name_prefix": "",
"client_id": "",
"client_secret": "",
"image_offer": "",
"image_publisher": "",
"image_sku": "",
"location": "",
"object_id": "",
"package_name": "",
"package_path": "",
"script_imageconfig_path": "",
"script_windowsupdate_path": "",
"subscription_id": "",
"tenant_id": "",
"environment": ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment