{ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "tenant_id": "{{env `ARM_TENANT_ID`}}", "object_id": "{{env `ARM_OBJECT_ID`}}", "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "temp_resource_group_name": "{{env `TEMP_RESOURCE_GROUP_NAME`}}", "location": "{{env `ARM_RESOURCE_LOCATION`}}", "ssh_password": "{{env `SSH_PASSWORD`}}", "virtual_network_name": "{{env `VNET_NAME`}}", "virtual_network_resource_group_name": "{{env `VNET_RESOURCE_GROUP`}}", "virtual_network_subnet_name": "{{env `VNET_SUBNET`}}", "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", "vm_size": "Standard_D4_v2", "run_scan_antivirus": "false", "root_folder": "C:", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", "imagedata_file": "C:\\imagedata.json", "metadata_file": "C:\\image\\metadata.txt", "helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\", "commit_id": "LATEST", "install_user": "installer", "install_password": null, "capture_name_prefix": "packer", "image_version": "dev", "image_os": "win19", "github_feed_token": "{{env `GITHUB_FEED_TOKEN`}}", "go_versions": "1.9, 1.10, 1.11, 1.12, 1.13, 1.14", "go_default": "1.14" }, "sensitive-variables": ["install_password", "ssh_password", "client_secret", "github_feed_token"], "builders": [ { "name": "vhd", "type": "azure-arm", "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", "subscription_id": "{{user `subscription_id`}}", "object_id": "{{user `object_id`}}", "tenant_id": "{{user `tenant_id`}}", "os_disk_size_gb": "256", "location": "{{user `location`}}", "vm_size": "{{user `vm_size`}}", "resource_group_name": "{{user `resource_group`}}", "storage_account": "{{user `storage_account`}}", "temp_resource_group_name": "{{user `temp_resource_group_name`}}", "capture_container_name": "images", "capture_name_prefix": "{{user `capture_name_prefix`}}", "virtual_network_name": "{{user `virtual_network_name`}}", "virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}", "virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}", "private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}", "os_type": "Windows", "image_publisher": "MicrosoftWindowsServer", "image_offer": "WindowsServer", "image_sku": "2019-Datacenter", "communicator": "winrm", "winrm_use_ssl": "true", "winrm_insecure": "true", "winrm_username": "packer" } ], "provisioners": [ { "type": "powershell", "inline":[ "New-Item -Path {{user `image_folder`}} -ItemType Directory -Force", "Write-Output {{user `commit_id`}} > {{user `commit_file`}}", "Write-Host (Get-Content -Path {{user `commit_file`}})" ] }, { "type": "file", "source": "{{ template_dir }}/scripts/ImageHelpers", "destination": "{{user `helper_script_folder`}}" }, { "type": "windows-shell", "inline": [ "net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y" , "net localgroup Administrators {{user `install_user`}} /add", "winrm set winrm/config/service/auth @{Basic=\"true\"}", "winrm get winrm/config/service/auth" ] }, { "type": "powershell", "inline": [ "if (-not ((net localgroup Administrators) -contains '{{user `install_user`}}')) { exit 1 }" ] }, { "type": "powershell", "environment_vars": [ "ImageVersion={{user `image_version`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Windows2019/Initialize-VM.ps1" ], "execution_policy": "unrestricted" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Update-DotnetTLS.ps1" ] }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-ContainersFeature.ps1" ] }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "inline": [ "setx ImageVersion {{user `image_version` }} /m", "setx ImageOS {{user `image_os` }} /m" ] }, { "type": "powershell", "environment_vars": [ "IMAGE_VERSION={{user `image_version`}}", "IMAGEDATA_FILE={{user `imagedata_file`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Update-ImageData.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Docker.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1" ] }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Docker.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-PowershellCore.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Windows2019/Update-DockerImages.ps1" ] }, { "type": "powershell", "valid_exit_codes": [ 0, 3010 ], "scripts":[ "{{ template_dir }}/scripts/Installers/Windows2019/Install-VS2019.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Wix.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Windows2019/Install-SSDTExtensions.ps1" ] }, { "type": "powershell", "valid_exit_codes": [ 0, 3010 ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-NET48.ps1" ] }, { "type": "powershell", "scripts": [ "{{ template_dir }}/scripts/Installers/Install-WDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" ], "execution_policy": "remotesigned" }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Wix.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Windows2019/Validate-SSDTExtensions.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-NET48.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-WDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AzureCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AzureDevOpsCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Packer.ps1" ] }, { "type": "file", "source": "{{template_dir}}/toolcache-2019.json", "destination": "{{user `root_folder`}}/toolcache.json" }, { "type": "powershell", "environment_vars":[ "GITHUB_FEED_TOKEN={{ user `github_feed_token` }}", "ROOT_FOLDER={{user `root_folder`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Download-ToolCache.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-OpenSSL.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Perl.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Git.ps1" ] }, { "type": "powershell", "environment_vars": [ "GO_VERSIONS={{user `go_versions`}}", "GO_DEFAULT={{user `go_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Go.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-PHP.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Rust.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Julia.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Sbt.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Svn.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Chrome.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Edge.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Firefox.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Selenium.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-IEWebDriver.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-VSWhere.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WinAppDriver.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-WinAppDriver.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-JavaTools.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Cmake.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AWS.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AWS-SAM.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-DACFx.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-SQLPowerShellTools.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-DotnetSDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1" ] }, { "type": "windows-shell", "inline": ["wmic product where \"name like '%%microsoft azure powershell%%'\" call uninstall /nointeractive"] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-MinGW.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-TypeScript.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Miniconda.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1" ] }, { "type": "powershell", "environment_vars": [ "ROOT_FOLDER={{user `root_folder`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Mercurial.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Jq.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Zstd.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-InnoSetup.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-GitVersion.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-NSIS.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-CloudFoundryCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-KubernetesCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Kind.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Bazel.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-RootCA.ps1" ] }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AzureModules.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-DotnetTLS.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AzureCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AWS-SAM.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AzureDevOpsCli.ps1" ] }, { "type": "powershell", "environment_vars":[ "ROOT_FOLDER={{user `root_folder`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-ToolCache.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-OpenSSL.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Perl.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Git.ps1" ] }, { "type": "powershell", "environment_vars": [ "GO_VERSIONS={{user `go_versions`}}", "GO_DEFAULT={{user `go_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Go.ps1" ] }, { "type": "powershell", "environment_vars": [ "ROOT_FOLDER={{user `root_folder`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Boost.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-PHP.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Rust.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Julia.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Svn.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Sbt.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Chrome.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Edge.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Firefox.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-SeleniumWebDrivers.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-NodeLts.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-JavaTools.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Cmake.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-DACFx.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-DotnetSDK.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-MysqlCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-SQLPowerShellTools.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-MinGW.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-TypeScript.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Miniconda.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-7zip.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Packer.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Mercurial.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Jq.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-InnoSetup.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-GitVersion.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-NSIS.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-CloudFoundryCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-KubernetesCli.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Kind.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" ] }, { "type": "file", "source": "C:\\InstalledSoftware.md", "destination": "{{ template_dir }}/Windows2019-Readme.md", "direction": "download" }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1" ] }, { "type": "windows-restart", "restart_timeout": "10m" }, { "type": "powershell", "environment_vars":[ "RUN_SCAN_ANTIVIRUS={{user `run_scan_antivirus`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Run-Antivirus.ps1" ] }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1" ] }, { "type": "powershell", "inline": [ "if( Test-Path $Env:SystemRoot\\System32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\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 } }" ] } ] }