Refactor Source image SKUs in packer templates (#13364)
* [ubuntu] Refactor image properties mapping to use source_image_marketplace_sku * Refactor Ubuntu and Windows image properties to simplify disk size handling and update marketplace SKU mappings * Refactor disk size handling to use coalesce for improved flexibility
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
locals {
|
||||
image_properties_map = {
|
||||
"ubuntu22" = {
|
||||
publisher = "canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
os_disk_size_gb = coalesce(var.os_disk_size_gb, 75)
|
||||
source_image_marketplace_sku = "canonical:0001-com-ubuntu-server-jammy:22_04-lts"
|
||||
os_disk_size_gb = 75
|
||||
},
|
||||
"ubuntu24" = {
|
||||
publisher = "canonical"
|
||||
offer = "ubuntu-24_04-lts"
|
||||
sku = "server-gen1"
|
||||
os_disk_size_gb = coalesce(var.os_disk_size_gb, 75)
|
||||
source_image_marketplace_sku = "canonical:ubuntu-24_04-lts:server-gen1"
|
||||
os_disk_size_gb = 75
|
||||
}
|
||||
}
|
||||
|
||||
image_properties = local.image_properties_map[var.image_os]
|
||||
source_image_marketplace_sku = local.image_properties_map[var.image_os].source_image_marketplace_sku
|
||||
os_disk_size_gb = coalesce(var.os_disk_size_gb, local.image_properties_map[var.image_os].os_disk_size_gb)
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ source "azure-arm" "image" {
|
||||
|
||||
allowed_inbound_ip_addresses = var.allowed_inbound_ip_addresses
|
||||
build_resource_group_name = var.build_resource_group_name
|
||||
image_offer = local.image_properties.offer
|
||||
image_publisher = local.image_properties.publisher
|
||||
image_sku = local.image_properties.sku
|
||||
image_publisher = split(":", local.source_image_marketplace_sku)[0]
|
||||
image_offer = split(":", local.source_image_marketplace_sku)[1]
|
||||
image_sku = split(":", local.source_image_marketplace_sku)[2]
|
||||
image_version = var.source_image_version
|
||||
location = var.location
|
||||
managed_image_name = var.managed_image_name
|
||||
managed_image_resource_group_name = var.managed_image_resource_group_name
|
||||
managed_image_storage_account_type = var.managed_image_storage_account_type
|
||||
os_disk_size_gb = local.image_properties.os_disk_size_gb
|
||||
os_disk_size_gb = local.os_disk_size_gb
|
||||
os_type = var.image_os_type
|
||||
private_virtual_network_with_public_ip = var.private_virtual_network_with_public_ip
|
||||
ssh_clear_authorized_keys = var.ssh_clear_authorized_keys
|
||||
|
||||
Reference in New Issue
Block a user