Created
December 25, 2021 18:53
-
-
Save alventech/b20fd1f1fba78dc6f89658e90b2688b6 to your computer and use it in GitHub Desktop.
Packer_w10_20h2_SIG_HCL2
This file contains 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
# This file was autogenerated by the 'packer hcl2_upgrade' command. We | |
# recommend double checking that everything is correct before going forward. We | |
# also recommend treating this file as disposable. The HCL2 blocks in this | |
# file can be moved to other files. For example, the variable blocks could be | |
# moved to their own 'variables.pkr.hcl' file, etc. Those files need to be | |
# suffixed with '.pkr.hcl' to be visible to Packer. To use multiple files at | |
# once they also need to be in the same folder. 'packer inspect folder/' | |
# will describe to you what is in that folder. | |
# Avoid mixing go templating calls ( for example ```{{ upper(`string`) }}``` ) | |
# and HCL2 calls (for example '${ var.string_value_example }' ). They won't be | |
# executed together and the outcome will be unknown. | |
# All generated input variables will be of 'string' type as this is how Packer JSON | |
# views them; you can change their type later on. Read the variables type | |
# constraints documentation | |
# https://www.packer.io/docs/templates/hcl_templates/variables#type-constraints for more info. | |
variable "WorkingDirectory" { | |
type = string | |
default = "${env("System_DefaultWorkingDirectory")}" | |
} | |
variable "client_id" { | |
type = string | |
default = "" | |
} | |
variable "client_secret" { | |
type = string | |
default = "" | |
} | |
variable "image_version" { | |
type = string | |
default = "" | |
} | |
variable "subscription_id" { | |
type = string | |
default = "" | |
} | |
variable "tenant_id" { | |
type = string | |
default = "" | |
} | |
# The "legacy_isotime" function has been provided for backwards compatability, but we recommend switching to the timestamp and formatdate functions. | |
# source blocks are generated from your builders; a source can be referenced in | |
# build blocks. A build block runs provisioner and post-processors on a | |
# source. Read the documentation for source blocks here: | |
# https://www.packer.io/docs/templates/hcl_templates/blocks/source | |
source "azure-arm" "autogenerated_1" { | |
async_resourcegroup_delete = true | |
#build_resource_group_name = "wvd-packer-template" | |
client_id = var.client_id | |
client_secret = var.client_secret | |
communicator = "winrm" | |
image_offer = "Windows-10" | |
image_publisher = "MicrosoftWindowsDesktop" | |
image_sku = "20h2-evd-g2" | |
location = "westeurope" | |
managed_image_name = "wvd-${legacy_isotime("200601020304")}" | |
managed_image_resource_group_name = "Packer" | |
os_type = "Windows" | |
shared_image_gallery_destination { | |
gallery_name = "PackerSIG" | |
image_name = "Packerimgdef" | |
image_version = var.image_version | |
replication_regions = ["westeurope"] | |
resource_group = "Packer" | |
subscription = var.subscription_id | |
} | |
subscription_id = var.subscription_id | |
tenant_id = var.tenant_id | |
vm_size = "Standard_DS2_v2" | |
winrm_insecure = "true" | |
winrm_timeout = "3m" | |
winrm_use_ssl = "true" | |
winrm_username = "packer" | |
} | |
# a build block invokes sources and runs provisioning steps on them. The | |
# documentation for build blocks can be found here: | |
# https://www.packer.io/docs/templates/hcl_templates/blocks/build | |
build { | |
sources = ["source.azure-arm.autogenerated_1"] | |
provisioner "powershell" { | |
inline = [" # NOTE: the following *3* lines are only needed if the you have installed the Guest Agent.", " while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }", " # while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }", " while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }", "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 /mode:vm", "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