diff --git a/helpers/GenerateResourcesAndImage.ps1 b/helpers/GenerateResourcesAndImage.ps1 index adda6effb..1f863b67f 100644 --- a/helpers/GenerateResourcesAndImage.ps1 +++ b/helpers/GenerateResourcesAndImage.ps1 @@ -119,6 +119,8 @@ Function GenerateResourcesAndImage { The default is 'ask'. .PARAMETER Tags Tags to be applied to the Azure resources created. + .PARAMETER PluginVersion + Specify the version of the packer Azure plugin to use. The default is "2.2.1". .EXAMPLE GenerateResourcesAndImage -SubscriptionId {YourSubscriptionId} -ResourceGroupName "shsamytest1" -ImageGenerationRepositoryRoot "C:\runner-images" -ImageType Ubuntu2004 -AzureLocation "East US" #> @@ -144,6 +146,8 @@ Function GenerateResourcesAndImage { [Parameter(Mandatory = $False)] [string] $AzureTenantId, [Parameter(Mandatory = $False)] + [string] $PluginVersion = "2.2.1", + [Parameter(Mandatory = $False)] [switch] $RestrictToAgentIpAddress, [Parameter(Mandatory = $False)] [switch] $Force, @@ -218,7 +222,7 @@ Function GenerateResourcesAndImage { $InstallPassword = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper() Write-Host "Downloading packer plugins..." - & $PackerBinary init $TemplatePath + & $PackerBinary plugins install github.com/hashicorp/azure $PluginVersion if ($LastExitCode -ne 0) { throw "Packer plugins download failed." diff --git a/images.CI/linux-and-win/build-image.ps1 b/images.CI/linux-and-win/build-image.ps1 index 081783032..626dd188d 100644 --- a/images.CI/linux-and-win/build-image.ps1 +++ b/images.CI/linux-and-win/build-image.ps1 @@ -8,6 +8,7 @@ param( [String] [Parameter (Mandatory=$true)] $TempResourceGroupName, [String] [Parameter (Mandatory=$true)] $SubscriptionId, [String] [Parameter (Mandatory=$true)] $TenantId, + [String] [Parameter (Mandatory=$false)] $pluginVersion = "2.2.1", [String] [Parameter (Mandatory=$false)] $VirtualNetworkName, [String] [Parameter (Mandatory=$false)] $VirtualNetworkRG, [String] [Parameter (Mandatory=$false)] $VirtualNetworkSubnet, @@ -40,7 +41,7 @@ Write-Host "Show Packer Version" packer --version Write-Host "Download packer plugins" -packer init $TemplatePath +packer plugins install github.com/hashicorp/azure $pluginVersion Write-Host "Validate packer template" packer validate -syntax-only $TemplatePath diff --git a/images/ubuntu/templates/ubuntu-20.04.pkr.hcl b/images/ubuntu/templates/ubuntu-20.04.pkr.hcl index d8d821bcd..8839e11c0 100644 --- a/images/ubuntu/templates/ubuntu-20.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-20.04.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" } diff --git a/images/ubuntu/templates/ubuntu-22.04.pkr.hcl b/images/ubuntu/templates/ubuntu-22.04.pkr.hcl index 6dd0abf17..0af16d284 100644 --- a/images/ubuntu/templates/ubuntu-22.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-22.04.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" } diff --git a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl index 7f02ff162..9e2ba3810 100644 --- a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" } diff --git a/images/ubuntu/templates/ubuntu-minimal.pkr.hcl b/images/ubuntu/templates/ubuntu-minimal.pkr.hcl index 634e76d31..a2e7d362b 100644 --- a/images/ubuntu/templates/ubuntu-minimal.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-minimal.pkr.hcl @@ -1,11 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} locals { image_os = "ubuntu22" diff --git a/images/windows/templates/windows-2019.pkr.hcl b/images/windows/templates/windows-2019.pkr.hcl index 1ec030585..ac837c559 100644 --- a/images/windows/templates/windows-2019.pkr.hcl +++ b/images/windows/templates/windows-2019.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" } diff --git a/images/windows/templates/windows-2022.pkr.hcl b/images/windows/templates/windows-2022.pkr.hcl index 0c66a7dbf..98c6034cf 100644 --- a/images/windows/templates/windows-2022.pkr.hcl +++ b/images/windows/templates/windows-2022.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" } diff --git a/images/windows/templates/windows-2025.pkr.hcl b/images/windows/templates/windows-2025.pkr.hcl index f1f3fdc55..72eda50e2 100644 --- a/images/windows/templates/windows-2025.pkr.hcl +++ b/images/windows/templates/windows-2025.pkr.hcl @@ -1,12 +1,3 @@ -packer { - required_plugins { - azure = { - source = "github.com/hashicorp/azure" - version = "1.4.5" - } - } -} - locals { managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}" }