Skip to content

Commit b28a104

Browse files
Add the ability to specify Packer Azure plugin version (#11587)
1 parent a4026a1 commit b28a104

9 files changed

+7
-64
lines changed

helpers/GenerateResourcesAndImage.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Function GenerateResourcesAndImage {
119119
The default is 'ask'.
120120
.PARAMETER Tags
121121
Tags to be applied to the Azure resources created.
122+
.PARAMETER PluginVersion
123+
Specify the version of the packer Azure plugin to use. The default is "2.2.1".
122124
.EXAMPLE
123125
GenerateResourcesAndImage -SubscriptionId {YourSubscriptionId} -ResourceGroupName "shsamytest1" -ImageGenerationRepositoryRoot "C:\runner-images" -ImageType Ubuntu2004 -AzureLocation "East US"
124126
#>
@@ -144,6 +146,8 @@ Function GenerateResourcesAndImage {
144146
[Parameter(Mandatory = $False)]
145147
[string] $AzureTenantId,
146148
[Parameter(Mandatory = $False)]
149+
[string] $PluginVersion = "2.2.1",
150+
[Parameter(Mandatory = $False)]
147151
[switch] $RestrictToAgentIpAddress,
148152
[Parameter(Mandatory = $False)]
149153
[switch] $Force,
@@ -218,7 +222,7 @@ Function GenerateResourcesAndImage {
218222
$InstallPassword = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper()
219223

220224
Write-Host "Downloading packer plugins..."
221-
& $PackerBinary init $TemplatePath
225+
& $PackerBinary plugins install github.com/hashicorp/azure $PluginVersion
222226

223227
if ($LastExitCode -ne 0) {
224228
throw "Packer plugins download failed."

images.CI/linux-and-win/build-image.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ param(
88
[String] [Parameter (Mandatory=$true)] $TempResourceGroupName,
99
[String] [Parameter (Mandatory=$true)] $SubscriptionId,
1010
[String] [Parameter (Mandatory=$true)] $TenantId,
11+
[String] [Parameter (Mandatory=$false)] $pluginVersion = "2.2.1",
1112
[String] [Parameter (Mandatory=$false)] $VirtualNetworkName,
1213
[String] [Parameter (Mandatory=$false)] $VirtualNetworkRG,
1314
[String] [Parameter (Mandatory=$false)] $VirtualNetworkSubnet,
@@ -40,7 +41,7 @@ Write-Host "Show Packer Version"
4041
packer --version
4142

4243
Write-Host "Download packer plugins"
43-
packer init $TemplatePath
44+
packer plugins install github.com/hashicorp/azure $pluginVersion
4445

4546
Write-Host "Validate packer template"
4647
packer validate -syntax-only $TemplatePath

images/ubuntu/templates/ubuntu-20.04.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

images/ubuntu/templates/ubuntu-22.04.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

images/ubuntu/templates/ubuntu-24.04.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

images/ubuntu/templates/ubuntu-minimal.pkr.hcl

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
91

102
locals {
113
image_os = "ubuntu22"

images/windows/templates/windows-2019.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

images/windows/templates/windows-2022.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

images/windows/templates/windows-2025.pkr.hcl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
packer {
2-
required_plugins {
3-
azure = {
4-
source = "github.com/hashicorp/azure"
5-
version = "1.4.5"
6-
}
7-
}
8-
}
9-
101
locals {
112
managed_image_name = var.managed_image_name != "" ? var.managed_image_name : "packer-${var.image_os}-${var.image_version}"
123
}

0 commit comments

Comments
 (0)