Add the ability to specify Packer Azure plugin version (#11587)

This commit is contained in:
Alexey-Ayupov
2025-02-13 16:46:42 +01:00
committed by GitHub
parent a4026a1e8b
commit b28a1045e6
9 changed files with 7 additions and 64 deletions

View File

@@ -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."

View File

@@ -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

View File

@@ -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}"
}

View File

@@ -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}"
}

View File

@@ -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}"
}

View File

@@ -1,11 +1,3 @@
packer {
required_plugins {
azure = {
source = "github.com/hashicorp/azure"
version = "1.4.5"
}
}
}
locals {
image_os = "ubuntu22"

View File

@@ -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}"
}

View File

@@ -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}"
}

View File

@@ -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}"
}