diff --git a/images.CI/linux-and-win/azure-pipelines/image-generation.yml b/images.CI/linux-and-win/azure-pipelines/image-generation.yml index 9cc38d5e..2e31962f 100644 --- a/images.CI/linux-and-win/azure-pipelines/image-generation.yml +++ b/images.CI/linux-and-win/azure-pipelines/image-generation.yml @@ -31,7 +31,10 @@ jobs: $ImageType = "${{ parameters.image_type }}" $TemplateDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "win" } $TemplateDirectoryPath = Join-Path "images" $TemplateDirectoryName | Resolve-Path - $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json" + $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl" + if ( -not (Test-Path $TemplatePath) ) { + $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json" + } Write-Host "##vso[task.setvariable variable=TemplateDirectoryPath;]$TemplateDirectoryPath" Write-Host "##vso[task.setvariable variable=TemplatePath;]$TemplatePath" diff --git a/images.CI/linux-and-win/build-image.ps1 b/images.CI/linux-and-win/build-image.ps1 index 41d03190..27b414d8 100644 --- a/images.CI/linux-and-win/build-image.ps1 +++ b/images.CI/linux-and-win/build-image.ps1 @@ -22,7 +22,7 @@ if (-not (Test-Path $TemplatePath)) # Set Image repository path env variable, this is a workaround for Ubuntu 22.04 until this is fixed https://github.com/hashicorp/packer/issues/11733 $env:ImageRepositoryPath = "." -$Image = [io.path]::GetFileNameWithoutExtension($TemplatePath) +$Image = [io.path]::GetFileName($TemplatePath).Split(".")[0] $TempResourceGroupName = "${ResourcesNamePrefix}_${Image}" $InstallPassword = [System.GUID]::NewGuid().ToString().ToUpper() @@ -62,4 +62,4 @@ packer build -var "capture_name_prefix=$ResourcesNamePrefix" ` $currentString = $_ $sensitiveString = $SensitiveData | Where-Object { $currentString -match $_ } $sensitiveString -eq $null - } \ No newline at end of file + } diff --git a/images/linux/ubuntu2204.json b/images/linux/ubuntu2204.json deleted file mode 100644 index 518eb059..00000000 --- a/images/linux/ubuntu2204.json +++ /dev/null @@ -1,367 +0,0 @@ -{ - "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`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", - "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`}}", - "image_repository_path": "{{env `IMAGEREPOSITORYPATH`}}", - "image_folder": "/imagegeneration", - "imagedata_file": "/imagegeneration/imagedata.json", - "installer_script_folder": "/imagegeneration/installers", - "helper_script_folder": "/imagegeneration/helpers", - "vm_size": "Standard_D4s_v4", - "capture_name_prefix": "packer", - "image_version": "dev", - "image_os": "ubuntu22", - "run_validation_diskspace": "false", - "dockerhub_login": "{{env `DOCKERHUB_LOGIN`}}", - "dockerhub_password": "{{env `DOCKERHUB_PASSWORD`}}" - }, - "sensitive-variables": [ - "client_secret" - ], - "builders": [ - { - "type": "azure-arm", - "client_id": "{{user `client_id`}}", - "client_secret": "{{user `client_secret`}}", - "subscription_id": "{{user `subscription_id`}}", - "tenant_id": "{{user `tenant_id`}}", - "location": "{{user `location`}}", - "vm_size": "{{user `vm_size`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", - "build_resource_group_name": "{{user `build_resource_group_name`}}", - "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`}}", - "allowed_inbound_ip_addresses": "{{user `allowed_inbound_ip_addresses`}}", - "user_data_file": "{{user `image_repository_path`}}/images/linux/scripts/base/configure-legacy-ssh.sh", - "os_type": "Linux", - "image_publisher": "canonical", - "image_offer": "0001-com-ubuntu-server-jammy", - "image_sku": "22_04-lts", - "os_disk_size_gb": "86" - } - ], - "provisioners": [ - { - "type": "shell", - "inline": [ - "mkdir {{user `image_folder`}}", - "chmod 777 {{user `image_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "{{template_dir}}/scripts/base/apt-mock.sh", - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/base/repos.sh" - ], - "environment_vars": [ - "DEBIAN_FRONTEND=noninteractive" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "{{template_dir}}/scripts/base/apt.sh", - "environment_vars": [ - "DEBIAN_FRONTEND=noninteractive" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "{{template_dir}}/scripts/base/limits.sh", - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "file", - "source": "{{template_dir}}/scripts/helpers", - "destination": "{{user `helper_script_folder`}}" - }, - { - "type": "file", - "source": "{{template_dir}}/scripts/installers", - "destination": "{{user `installer_script_folder`}}" - }, - { - "type": "file", - "source": "{{ template_dir }}/post-generation", - "destination": "{{user `image_folder`}}" - }, - { - "type": "file", - "source": "{{template_dir}}/scripts/tests", - "destination": "{{user `image_folder`}}" - }, - { - "type": "file", - "source": "{{ template_dir }}/scripts/SoftwareReport", - "destination": "{{user `image_folder`}}" - }, - { - "type": "file", - "source": "{{template_dir}}/toolsets/toolset-2204.json", - "destination": "{{user `installer_script_folder`}}/toolset.json" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/preimagedata.sh" - ], - "environment_vars": [ - "IMAGE_VERSION={{user `image_version`}}", - "IMAGEDATA_FILE={{user `imagedata_file`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/configure-environment.sh" - ], - "environment_vars": [ - "IMAGE_VERSION={{user `image_version`}}", - "IMAGE_OS={{user `image_os`}}", - "HELPER_SCRIPTS={{user `helper_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/complete-snap-setup.sh", - "{{template_dir}}/scripts/installers/powershellcore.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/Install-PowerShellModules.ps1", - "{{template_dir}}/scripts/installers/Install-AzureModules.ps1" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/docker-compose.sh", - "{{template_dir}}/scripts/installers/docker-moby.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", - "DOCKERHUB_LOGIN={{user `dockerhub_login`}}", - "DOCKERHUB_PASSWORD={{user `dockerhub_password`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/azcopy.sh", - "{{template_dir}}/scripts/installers/azure-cli.sh", - "{{template_dir}}/scripts/installers/azure-devops-cli.sh", - "{{template_dir}}/scripts/installers/basic.sh", - "{{template_dir}}/scripts/installers/bicep.sh", - "{{template_dir}}/scripts/installers/aliyun-cli.sh", - "{{template_dir}}/scripts/installers/apache.sh", - "{{template_dir}}/scripts/installers/aws.sh", - "{{template_dir}}/scripts/installers/clang.sh", - "{{template_dir}}/scripts/installers/cmake.sh", - "{{template_dir}}/scripts/installers/codeql-bundle.sh", - "{{template_dir}}/scripts/installers/dotnetcore-sdk.sh", - "{{template_dir}}/scripts/installers/gcc.sh", - "{{template_dir}}/scripts/installers/gfortran.sh", - "{{template_dir}}/scripts/installers/git.sh", - "{{template_dir}}/scripts/installers/github-cli.sh", - "{{template_dir}}/scripts/installers/google-chrome.sh", - "{{template_dir}}/scripts/installers/google-cloud-sdk.sh", - "{{template_dir}}/scripts/installers/haskell.sh", - "{{template_dir}}/scripts/installers/heroku.sh", - "{{template_dir}}/scripts/installers/kubernetes-tools.sh", - "{{template_dir}}/scripts/installers/oc.sh", - "{{template_dir}}/scripts/installers/miniconda.sh", - "{{template_dir}}/scripts/installers/mysql.sh", - "{{template_dir}}/scripts/installers/sqlpackage.sh", - "{{template_dir}}/scripts/installers/nginx.sh", - "{{template_dir}}/scripts/installers/nvm.sh", - "{{template_dir}}/scripts/installers/nodejs.sh", - "{{template_dir}}/scripts/installers/bazel.sh", - "{{template_dir}}/scripts/installers/oras-cli.sh", - "{{template_dir}}/scripts/installers/php.sh", - "{{template_dir}}/scripts/installers/postgresql.sh", - "{{template_dir}}/scripts/installers/pulumi.sh", - "{{template_dir}}/scripts/installers/ruby.sh", - "{{template_dir}}/scripts/installers/r.sh", - "{{template_dir}}/scripts/installers/rust.sh", - "{{template_dir}}/scripts/installers/julia.sh", - "{{template_dir}}/scripts/installers/sbt.sh", - "{{template_dir}}/scripts/installers/terraform.sh", - "{{template_dir}}/scripts/installers/packer.sh", - "{{template_dir}}/scripts/installers/vcpkg.sh", - "{{template_dir}}/scripts/installers/dpkg-config.sh", - "{{template_dir}}/scripts/installers/yq.sh", - "{{template_dir}}/scripts/installers/pypy.sh", - "{{template_dir}}/scripts/installers/python.sh", - "{{template_dir}}/scripts/installers/graalvm.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", - "DEBIAN_FRONTEND=noninteractive" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/Install-Toolset.ps1", - "{{template_dir}}/scripts/installers/Configure-Toolset.ps1" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/pipx-packages.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/homebrew.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "DEBIAN_FRONTEND=noninteractive", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "{{template_dir}}/scripts/base/snap.sh", - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "expect_disconnect": true, - "scripts": [ - "{{template_dir}}/scripts/base/reboot.sh" - ], - "execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "pause_before": "60s", - "start_retry_timeout": "10m", - "scripts": [ - "{{template_dir}}/scripts/installers/cleanup.sh" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "{{template_dir}}/scripts/base/apt-mock-remove.sh", - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "inline": [ - "pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}", - "pwsh -File {{user `image_folder`}}/tests/RunAll-Tests.ps1 -OutputDirectory {{user `image_folder`}}" - ], - "environment_vars": [ - "IMAGE_VERSION={{user `image_version`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ] - }, - { - "type": "file", - "source": "{{user `image_folder`}}/Ubuntu-Readme.md", - "destination": "{{template_dir}}/Ubuntu2204-Readme.md", - "direction": "download" - }, - { - "type": "shell", - "scripts":[ - "{{template_dir}}/scripts/installers/post-deployment.sh" - ], - "environment_vars":[ - "HELPER_SCRIPT_FOLDER={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", - "IMAGE_FOLDER={{user `image_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts":[ - "{{template_dir}}/scripts/installers/validate-disk-space.sh" - ], - "environment_vars": [ - "RUN_VALIDATION={{user `run_validation_diskspace`}}" - ] - }, - { - "type": "file", - "source": "{{template_dir}}/config/ubuntu2204.conf", - "destination": "/tmp/" - }, - { - "type": "shell", - "inline": [ - "mkdir -p /etc/vsts", - "cp /tmp/ubuntu2204.conf /etc/vsts/machine_instance.conf" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "inline": [ - "sleep 30", - "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - } - ] -} diff --git a/images/linux/ubuntu2204.pkr.hcl b/images/linux/ubuntu2204.pkr.hcl new file mode 100644 index 00000000..4b1f3030 --- /dev/null +++ b/images/linux/ubuntu2204.pkr.hcl @@ -0,0 +1,389 @@ + +variable "allowed_inbound_ip_addresses" { + default = [] +} + +variable "build_resource_group_name" { + type = string + default = "${env("BUILD_RESOURCE_GROUP_NAME")}" +} + +variable "capture_name_prefix" { + type = string + default = "packer" +} + +variable "client_id" { + type = string + default = "${env("ARM_CLIENT_ID")}" +} + +variable "client_secret" { + type = string + default = "${env("ARM_CLIENT_SECRET")}" + sensitive = true +} + +variable "commit_url" { + type = string + default = "" +} + +variable "dockerhub_login" { + type = string + default = "${env("DOCKERHUB_LOGIN")}" +} + +variable "dockerhub_password" { + type = string + default = "${env("DOCKERHUB_PASSWORD")}" +} + +variable "helper_script_folder" { + type = string + default = "/imagegeneration/helpers" +} + +variable "image_folder" { + type = string + default = "/imagegeneration" +} + +variable "image_os" { + type = string + default = "ubuntu22" +} + +variable "image_repository_path" { + type = string + default = "${env("IMAGEREPOSITORYPATH")}" +} + +variable "image_version" { + type = string + default = "dev" +} + +variable "imagedata_file" { + type = string + default = "/imagegeneration/imagedata.json" +} + +variable "installer_script_folder" { + type = string + default = "/imagegeneration/installers" +} + +variable "install_password" { + type = string + default = "" +} + +variable "location" { + type = string + default = "${env("ARM_RESOURCE_LOCATION")}" +} + +variable "private_virtual_network_with_public_ip" { + type = bool + default = false +} + +variable "resource_group" { + type = string + default = "${env("ARM_RESOURCE_GROUP")}" +} + +variable "run_validation_diskspace" { + type = bool + default = false +} + +variable "storage_account" { + type = string + default = "${env("ARM_STORAGE_ACCOUNT")}" +} + +variable "subscription_id" { + type = string + default = "${env("ARM_SUBSCRIPTION_ID")}" +} + +variable "temp_resource_group_name" { + type = string + default = "${env("TEMP_RESOURCE_GROUP_NAME")}" +} + +variable "tenant_id" { + type = string + default = "${env("ARM_TENANT_ID")}" +} + +variable "virtual_network_name" { + type = string + default = "${env("VNET_NAME")}" +} + +variable "virtual_network_resource_group_name" { + type = string + default = "${env("VNET_RESOURCE_GROUP")}" +} + +variable "virtual_network_subnet_name" { + type = string + default = "${env("VNET_SUBNET")}" +} + +variable "vm_size" { + type = string + default = "Standard_D4s_v4" +} + +source "azure-arm" "build_vhd" { + allowed_inbound_ip_addresses = "${var.allowed_inbound_ip_addresses}" + build_resource_group_name = "${var.build_resource_group_name}" + capture_container_name = "images" + capture_name_prefix = "${var.capture_name_prefix}" + client_id = "${var.client_id}" + client_secret = "${var.client_secret}" + image_offer = "0001-com-ubuntu-server-jammy" + image_publisher = "canonical" + image_sku = "22_04-lts" + location = "${var.location}" + os_disk_size_gb = "86" + os_type = "Linux" + private_virtual_network_with_public_ip = "${var.private_virtual_network_with_public_ip}" + resource_group_name = "${var.resource_group}" + storage_account = "${var.storage_account}" + subscription_id = "${var.subscription_id}" + temp_resource_group_name = "${var.temp_resource_group_name}" + tenant_id = "${var.tenant_id}" + user_data_file = "${var.image_repository_path}/images/linux/scripts/base/configure-legacy-ssh.sh" + virtual_network_name = "${var.virtual_network_name}" + virtual_network_resource_group_name = "${var.virtual_network_resource_group_name}" + virtual_network_subnet_name = "${var.virtual_network_subnet_name}" + vm_size = "${var.vm_size}" +} + +build { + sources = ["source.azure-arm.build_vhd"] + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + inline = ["mkdir ${var.image_folder}", "chmod 777 ${var.image_folder}"] + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/scripts/base/apt-mock.sh" + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/base/repos.sh"] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/scripts/base/apt.sh" + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/scripts/base/limits.sh" + } + + provisioner "file" { + destination = "${var.helper_script_folder}" + source = "${path.root}/scripts/helpers" + } + + provisioner "file" { + destination = "${var.installer_script_folder}" + source = "${path.root}/scripts/installers" + } + + provisioner "file" { + destination = "${var.image_folder}" + source = "${path.root}/post-generation" + } + + provisioner "file" { + destination = "${var.image_folder}" + source = "${path.root}/scripts/tests" + } + + provisioner "file" { + destination = "${var.image_folder}" + source = "${path.root}/scripts/SoftwareReport" + } + + provisioner "file" { + destination = "${var.installer_script_folder}/toolset.json" + source = "${path.root}/toolsets/toolset-2204.json" + } + + provisioner "shell" { + environment_vars = ["IMAGE_VERSION=${var.image_version}", "IMAGEDATA_FILE=${var.imagedata_file}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/preimagedata.sh"] + } + + provisioner "shell" { + environment_vars = ["IMAGE_VERSION=${var.image_version}", "IMAGE_OS=${var.image_os}", "HELPER_SCRIPTS=${var.helper_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/configure-environment.sh"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/complete-snap-setup.sh", "${path.root}/scripts/installers/powershellcore.sh"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/Install-PowerShellModules.ps1", "${path.root}/scripts/installers/Install-AzureModules.ps1"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}", "DOCKERHUB_LOGIN=${var.dockerhub_login}", "DOCKERHUB_PASSWORD=${var.dockerhub_password}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/docker-compose.sh", "${path.root}/scripts/installers/docker-moby.sh"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}", "DEBIAN_FRONTEND=noninteractive"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = [ + "${path.root}/scripts/installers/azcopy.sh", + "${path.root}/scripts/installers/azure-cli.sh", + "${path.root}/scripts/installers/azure-devops-cli.sh", + "${path.root}/scripts/installers/basic.sh", + "${path.root}/scripts/installers/bicep.sh", + "${path.root}/scripts/installers/aliyun-cli.sh", + "${path.root}/scripts/installers/apache.sh", + "${path.root}/scripts/installers/aws.sh", + "${path.root}/scripts/installers/clang.sh", + "${path.root}/scripts/installers/cmake.sh", + "${path.root}/scripts/installers/codeql-bundle.sh", + "${path.root}/scripts/installers/dotnetcore-sdk.sh", + "${path.root}/scripts/installers/gcc.sh", + "${path.root}/scripts/installers/gfortran.sh", + "${path.root}/scripts/installers/git.sh", + "${path.root}/scripts/installers/github-cli.sh", + "${path.root}/scripts/installers/google-chrome.sh", + "${path.root}/scripts/installers/google-cloud-sdk.sh", + "${path.root}/scripts/installers/haskell.sh", + "${path.root}/scripts/installers/heroku.sh", + "${path.root}/scripts/installers/kubernetes-tools.sh", + "${path.root}/scripts/installers/oc.sh", + "${path.root}/scripts/installers/miniconda.sh", + "${path.root}/scripts/installers/mysql.sh", + "${path.root}/scripts/installers/sqlpackage.sh", + "${path.root}/scripts/installers/nginx.sh", + "${path.root}/scripts/installers/nvm.sh", + "${path.root}/scripts/installers/nodejs.sh", + "${path.root}/scripts/installers/bazel.sh", + "${path.root}/scripts/installers/oras-cli.sh", + "${path.root}/scripts/installers/php.sh", + "${path.root}/scripts/installers/postgresql.sh", + "${path.root}/scripts/installers/pulumi.sh", + "${path.root}/scripts/installers/ruby.sh", + "${path.root}/scripts/installers/r.sh", + "${path.root}/scripts/installers/rust.sh", + "${path.root}/scripts/installers/julia.sh", + "${path.root}/scripts/installers/sbt.sh", + "${path.root}/scripts/installers/terraform.sh", + "${path.root}/scripts/installers/packer.sh", + "${path.root}/scripts/installers/vcpkg.sh", + "${path.root}/scripts/installers/dpkg-config.sh", + "${path.root}/scripts/installers/yq.sh", + "${path.root}/scripts/installers/pypy.sh", + "${path.root}/scripts/installers/python.sh", + "${path.root}/scripts/installers/graalvm.sh" + ] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/Install-Toolset.ps1", "${path.root}/scripts/installers/Configure-Toolset.ps1"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/pipx-packages.sh"] + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "DEBIAN_FRONTEND=noninteractive", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + execute_command = "/bin/sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/homebrew.sh"] + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/scripts/base/snap.sh" + } + + provisioner "shell" { + execute_command = "/bin/sh -c '{{ .Vars }} {{ .Path }}'" + expect_disconnect = true + scripts = ["${path.root}/scripts/base/reboot.sh"] + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + pause_before = "1m0s" + scripts = ["${path.root}/scripts/installers/cleanup.sh"] + start_retry_timeout = "10m" + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/scripts/base/apt-mock-remove.sh" + } + + provisioner "shell" { + environment_vars = ["IMAGE_VERSION=${var.image_version}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + inline = ["pwsh -File ${var.image_folder}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory ${var.image_folder}", "pwsh -File ${var.image_folder}/tests/RunAll-Tests.ps1 -OutputDirectory ${var.image_folder}"] + } + + provisioner "file" { + destination = "${path.root}/Ubuntu2204-Readme.md" + direction = "download" + source = "${var.image_folder}/Ubuntu-Readme.md" + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPT_FOLDER=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}", "IMAGE_FOLDER=${var.image_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + scripts = ["${path.root}/scripts/installers/post-deployment.sh"] + } + + provisioner "shell" { + environment_vars = ["RUN_VALIDATION=${var.run_validation_diskspace}"] + scripts = ["${path.root}/scripts/installers/validate-disk-space.sh"] + } + + provisioner "file" { + destination = "/tmp/" + source = "${path.root}/config/ubuntu2204.conf" + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + inline = ["mkdir -p /etc/vsts", "cp /tmp/ubuntu2204.conf /etc/vsts/machine_instance.conf"] + } + + provisioner "shell" { + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + inline = ["sleep 30", "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"] + } + +}