Files
runner-images-sangeeth/images/windows/templates/windows-2022.json
2023-11-16 11:20:11 +01:00

357 lines
17 KiB
JSON

{
"variables": {
"client_id": "{{env `ARM_CLIENT_ID`}}",
"client_secret": "{{env `ARM_CLIENT_SECRET`}}",
"client_cert_path": "{{env `ARM_CLIENT_CERT_PATH`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
"tenant_id": "{{env `ARM_TENANT_ID`}}",
"object_id": "{{env `ARM_OBJECT_ID`}}",
"managed_image_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
"managed_image_storage_account_type": "Premium_LRS",
"build_resource_group_name": "{{env `BUILD_RESOURCE_GROUP_NAME`}}",
"temp_resource_group_name": "{{env `TEMP_RESOURCE_GROUP_NAME`}}",
"location": "{{env `ARM_RESOURCE_LOCATION`}}",
"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`}}",
"allowed_inbound_ip_addresses": "{{env `AGENT_IP`}}",
"vm_size": "Standard_F8s_v2",
"image_folder": "C:\\image",
"imagedata_file": "C:\\imagedata.json",
"helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\",
"agent_tools_directory": "C:\\hostedtoolcache\\windows",
"install_user": "installer",
"install_password": null,
"managed_image_name": "packer-win22-dev",
"image_version": "dev",
"image_os": "win22"
},
"sensitive-variables": [
"install_password",
"client_secret"
],
"builders": [
{
"name": "image",
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_cert_path": "{{user `client_cert_path`}}",
"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`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"managed_image_resource_group_name": "{{user `managed_image_resource_group_name`}}",
"managed_image_storage_account_type": "{{user `managed_image_storage_account_type`}}",
"build_resource_group_name": "{{user `build_resource_group_name`}}",
"temp_resource_group_name": "{{user `temp_resource_group_name`}}",
"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`}}",
"allowed_inbound_ip_addresses": "{{user `allowed_inbound_ip_addresses`}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2022-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"
]
},
{
"type": "file",
"sources": [
"{{ template_dir }}/../assets",
"{{ template_dir }}/../scripts",
"{{ template_dir }}/../toolsets"
],
"destination": "{{user `image_folder`}}\\"
},
{
"type": "file",
"source": "{{ template_dir }}/../../../helpers/software-report-base",
"destination": "{{user `image_folder`}}\\scripts\\docs-gen\\"
},
{
"type": "powershell",
"inline": [
"Move-Item '{{user `image_folder`}}\\assets\\post-gen' 'C:\\post-generation'",
"Remove-Item -Recurse '{{user `image_folder`}}\\assets'",
"Move-Item '{{user `image_folder`}}\\scripts\\docs-gen' '{{user `image_folder`}}\\SoftwareReport'",
"Move-Item '{{user `image_folder`}}\\scripts\\helpers' '{{user `helper_script_folder`}}\\ImageHelpers'",
"New-Item -Type Directory -Path '{{user `helper_script_folder`}}\\TestsHelpers\\'",
"Move-Item '{{user `image_folder`}}\\scripts\\tests\\Helpers.psm1' '{{user `helper_script_folder`}}\\TestsHelpers\\TestsHelpers.psm1'",
"Move-Item '{{user `image_folder`}}\\scripts\\tests' '{{user `image_folder`}}\\tests'",
"Remove-Item -Recurse '{{user `image_folder`}}\\scripts'",
"Move-Item '{{user `image_folder`}}\\toolsets\\toolset-2022.json' '{{user `image_folder`}}\\toolset.json'",
"Remove-Item -Recurse '{{user `image_folder`}}\\toolsets'"
]
},
{
"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",
"inline": [
"bcdedit.exe /set TESTSIGNING ON"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
},
{
"type": "powershell",
"environment_vars": [
"IMAGE_VERSION={{user `image_version`}}",
"IMAGE_OS={{user `image_os`}}",
"AGENT_TOOLSDIRECTORY={{user `agent_tools_directory`}}",
"ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE=C:\\actionarchivecache\\",
"IMAGEDATA_FILE={{user `imagedata_file`}}"
],
"scripts": [
"{{ template_dir }}/../scripts/build/Configure-WindowsDefender.ps1",
"{{ template_dir }}/../scripts/build/Configure-PowerShell.ps1",
"{{ template_dir }}/../scripts/build/Install-PowershellModules.ps1",
"{{ template_dir }}/../scripts/build/Install-WindowsFeatures.ps1",
"{{ template_dir }}/../scripts/build/Install-Chocolatey.ps1",
"{{ template_dir }}/../scripts/build/Configure-BaseImage.ps1",
"{{ template_dir }}/../scripts/build/Configure-ImageDataFile.ps1",
"{{ template_dir }}/../scripts/build/Configure-SystemEnvironment.ps1",
"{{ template_dir }}/../scripts/build/Configure-DotnetSecureChannel.ps1"
],
"execution_policy": "unrestricted"
},
{
"type": "windows-restart",
"check_registry": true,
"restart_check_command": "powershell -command \"& {while ( (Get-WindowsOptionalFeature -Online -FeatureName Containers -ErrorAction SilentlyContinue).State -ne 'Enabled' ) { Start-Sleep 30; Write-Output 'InProgress' }}\"",
"restart_timeout": "10m"
},
{
"type": "powershell",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-Docker.ps1",
"{{ template_dir }}/../scripts/build/Install-DockerWinCred.ps1",
"{{ template_dir }}/../scripts/build/Install-DockerCompose.ps1",
"{{ template_dir }}/../scripts/build/Install-PowershellCore.ps1",
"{{ template_dir }}/../scripts/build/Install-WebPlatformInstaller.ps1",
"{{ template_dir }}/../scripts/build/Install-Runner.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout": "30m"
},
{
"type": "powershell",
"valid_exit_codes": [
0,
3010
],
"scripts": [
"{{ template_dir }}/../scripts/build/Install-VisualStudio.ps1",
"{{ template_dir }}/../scripts/build/Install-KubernetesTools.ps1"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
},
{
"type": "windows-restart",
"check_registry": true,
"restart_timeout": "10m"
},
{
"type": "powershell",
"pause_before": "2m",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-Wix.ps1",
"{{ template_dir }}/../scripts/build/Install-WDK.ps1",
"{{ template_dir }}/../scripts/build/Install-VSExtensions.ps1",
"{{ template_dir }}/../scripts/build/Install-AzureCli.ps1",
"{{ template_dir }}/../scripts/build/Install-AzureDevOpsCli.ps1",
"{{ template_dir }}/../scripts/build/Install-ChocolateyPackages.ps1",
"{{ template_dir }}/../scripts/build/Install-JavaTools.ps1",
"{{ template_dir }}/../scripts/build/Install-Kotlin.ps1",
"{{ template_dir }}/../scripts/build/Install-OpenSSL.ps1"
]
},
{
"type": "powershell",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-ServiceFabricSDK.ps1"
],
"execution_policy": "remotesigned"
},
{
"type": "windows-restart",
"restart_timeout": "10m"
},
{
"type": "windows-shell",
"inline": [
"wmic product where \"name like '%%microsoft azure powershell%%'\" call uninstall /nointeractive"
]
},
{
"type": "powershell",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-ActionsCache.ps1",
"{{ template_dir }}/../scripts/build/Install-Ruby.ps1",
"{{ template_dir }}/../scripts/build/Install-PyPy.ps1",
"{{ template_dir }}/../scripts/build/Install-Toolset.ps1",
"{{ template_dir }}/../scripts/build/Configure-Toolset.ps1",
"{{ template_dir }}/../scripts/build/Install-NodeJS.ps1",
"{{ template_dir }}/../scripts/build/Install-AndroidSDK.ps1",
"{{ template_dir }}/../scripts/build/Install-PowershellAzModules.ps1",
"{{ template_dir }}/../scripts/build/Install-Pipx.ps1",
"{{ template_dir }}/../scripts/build/Install-Git.ps1",
"{{ template_dir }}/../scripts/build/Install-GitHub-CLI.ps1",
"{{ template_dir }}/../scripts/build/Install-PHP.ps1",
"{{ template_dir }}/../scripts/build/Install-Rust.ps1",
"{{ template_dir }}/../scripts/build/Install-Sbt.ps1",
"{{ template_dir }}/../scripts/build/Install-Chrome.ps1",
"{{ template_dir }}/../scripts/build/Install-EdgeDriver.ps1",
"{{ template_dir }}/../scripts/build/Install-Firefox.ps1",
"{{ template_dir }}/../scripts/build/Install-Selenium.ps1",
"{{ template_dir }}/../scripts/build/Install-IEWebDriver.ps1",
"{{ template_dir }}/../scripts/build/Install-Apache.ps1",
"{{ template_dir }}/../scripts/build/Install-Nginx.ps1",
"{{ template_dir }}/../scripts/build/Install-Msys2.ps1",
"{{ template_dir }}/../scripts/build/Install-WinAppDriver.ps1",
"{{ template_dir }}/../scripts/build/Install-R.ps1",
"{{ template_dir }}/../scripts/build/Install-AWSTools.ps1",
"{{ template_dir }}/../scripts/build/Install-DACFx.ps1",
"{{ template_dir }}/../scripts/build/Install-MysqlCli.ps1",
"{{ template_dir }}/../scripts/build/Install-SQLPowerShellTools.ps1",
"{{ template_dir }}/../scripts/build/Install-SQLOLEDBDriver.ps1",
"{{ template_dir }}/../scripts/build/Install-DotnetSDK.ps1",
"{{ template_dir }}/../scripts/build/Install-Mingw64.ps1",
"{{ template_dir }}/../scripts/build/Install-Haskell.ps1",
"{{ template_dir }}/../scripts/build/Install-Stack.ps1",
"{{ template_dir }}/../scripts/build/Install-Miniconda.ps1",
"{{ template_dir }}/../scripts/build/Install-AzureCosmosDbEmulator.ps1",
"{{ template_dir }}/../scripts/build/Install-Mercurial.ps1",
"{{ template_dir }}/../scripts/build/Install-Zstd.ps1",
"{{ template_dir }}/../scripts/build/Install-NSIS.ps1",
"{{ template_dir }}/../scripts/build/Install-Vcpkg.ps1",
"{{ template_dir }}/../scripts/build/Install-PostgreSQL.ps1",
"{{ template_dir }}/../scripts/build/Install-Bazel.ps1",
"{{ template_dir }}/../scripts/build/Install-AliyunCli.ps1",
"{{ template_dir }}/../scripts/build/Install-RootCA.ps1",
"{{ template_dir }}/../scripts/build/Install-MongoDB.ps1",
"{{ template_dir }}/../scripts/build/Install-CodeQLBundle.ps1",
"{{ template_dir }}/../scripts/build/Configure-Diagnostics.ps1"
]
},
{
"type": "powershell",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-WindowsUpdates.ps1",
"{{ template_dir }}/../scripts/build/Configure-DynamicPort.ps1",
"{{ template_dir }}/../scripts/build/Configure-GDIProcessHandleQuota.ps1",
"{{ template_dir }}/../scripts/build/Configure-Shell.ps1",
"{{ template_dir }}/../scripts/build/Configure-DeveloperMode.ps1",
"{{ template_dir }}/../scripts/build/Install-LLVM.ps1"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
},
{
"type": "windows-restart",
"check_registry": true,
"restart_check_command": "powershell -command \"& {if ((-not (Get-Process TiWorker.exe -ErrorAction SilentlyContinue)) -and (-not [System.Environment]::HasShutdownStarted) ) { Write-Output 'Restart complete' }}\"",
"restart_timeout": "30m"
},
{
"type": "powershell",
"pause_before": "2m",
"scripts": [
"{{ template_dir }}/../scripts/build/Install-WindowsUpdatesAfterReboot.ps1",
"{{ template_dir }}/../scripts/tests/RunAll-Tests.ps1"
]
},
{
"type": "powershell",
"inline": [
"if (-not (Test-Path {{user `image_folder`}}\\tests\\testResults.xml)) { throw '{{user `image_folder`}}\\tests\\testResults.xml not found' }"
]
},
{
"type": "powershell",
"inline": [
"pwsh -File '{{user `image_folder`}}\\SoftwareReport\\Generate-SoftwareReport.ps1'"
],
"environment_vars": [
"IMAGE_VERSION={{user `image_version`}}"
]
},
{
"type": "powershell",
"inline": [
"if (-not (Test-Path C:\\software-report.md)) { throw 'C:\\software-report.md not found' }",
"if (-not (Test-Path C:\\software-report.json)) { throw 'C:\\software-report.json not found' }"
]
},
{
"type": "file",
"source": "C:\\software-report.md",
"destination": "{{ template_dir }}/../Windows2022-Readme.md",
"direction": "download"
},
{
"type": "file",
"source": "C:\\software-report.json",
"destination": "{{ template_dir }}/../software-report.json",
"direction": "download"
},
{
"type": "powershell",
"skip_clean": true,
"scripts": [
"{{ template_dir }}/../scripts/build/Install-NativeImages.ps1",
"{{ template_dir }}/../scripts/build/Configure-System.ps1",
"{{ template_dir }}/../scripts/build/Configure-User.ps1"
],
"environment_vars": [
"INSTALL_USER={{user `install_user`}}"
]
},
{
"type": "windows-restart",
"restart_timeout": "10m"
},
{
"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 /mode:vm /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 } }"
]
}
]
}