Created
June 30, 2019 18:53
-
-
Save marshyon/c0beccfbc7517917e28e0d20a5cc955f to your computer and use it in GitHub Desktop.
Packer json file to create a windows host on Azure and run commands to sysprep and activate a web server on the subsequent host
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
{ | |
"builders": [{ | |
"type": "azure-arm", | |
"client_id": "<client id here>", | |
"client_secret": "<client secret here>", | |
"tenant_id": "<tennant id here", | |
"subscription_id": "<subscription id here>", | |
"managed_image_resource_group_name": "myPackerGroup", | |
"managed_image_name": "myPackerImage", | |
"managed_image_resource_group_name": "packer_images", | |
"managed_image_name": "myWindowsPackerImage", | |
"os_type": "Windows", | |
"image_publisher": "MicrosoftWindowsServer", | |
"image_offer": "WindowsServer", | |
"image_sku": "2016-Datacenter", | |
"communicator": "winrm", | |
"winrm_use_ssl": true, | |
"winrm_insecure": true, | |
"winrm_timeout": "5m", | |
"winrm_username": "packer", | |
"azure_tags": { | |
"dept": "Engineering", | |
"task": "Image deployment" | |
}, | |
"location": "westeurope", | |
"vm_size": "Standard_DS2_v2" | |
}], | |
"provisioners": [{ | |
"type": "powershell", | |
"inline": [ | |
"Add-WindowsFeature Web-Server", | |
"& $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