在 HCL 文件中提供源图像详细信息,以便打包程序在 Azure 中自动化图像处理

问题描述 投票:0回答:1

packer 
  required_plugins {
    azure = {
      version = ">= 1.0.0"
      source  = "github.com/hashicorp/azure"
    }
  }
}

source "azure-arm" "example" {
  managed_image_name                 = "test-ubuntu-20.04img-${formatdate("DD-MMM-YYYY-hh-mm-ss", timestamp())}"  managed_image_resource_group_name  = var.gallery_resource_group
  managed_image_storage_account_type = "Standard_LRS"
  location                           = var.location

  # Using Azure CLI for authentication
  use_azure_cli_auth = true

  image_offer     = "0001-com-ubuntu-server-focal"
  image_publisher = "Canonical"
  image_sku       = "20_04-lts-gen2"

  os_type         = "Linux"
  vm_size         = "Standard_B4ms"
  os_disk_size_gb = 64

  shared_image_gallery_destination {
    resource_group       = var.gallery_resource_group
    gallery_name         = var.gallery_name
    image_name           = "test-ubuntu-20.04"
    image_version        = "1.0.0"
    replication_regions  = ["uaenorth"]
    storage_account_type = "Standard_LRS"
  }
}

build {
  sources = [
    "source.azure-arm.example"
  ]

  provisioner "shell" {
    execute_command = "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
    script          = "install.sh"
  }

我正在尝试使用上面的 HCL 文件使用打包器创建自定义图像。 我在天蓝色中有计算图像库,您可以在下面从天蓝色中看到 我想从 1.0.0 创建 1.0.2

但是我没有找到提供源图像详细信息的选项,我到底应该在 HCL 文件中提供上面的这些详细信息吗?

azure packer
1个回答
0
投票

请求的参数是

image_version
块内的
shared_gallery_image

shared_gallery_image {
  image_version = "1.0.0"
}

其默认值为最新版本。您还需要在块中指定更多输入参数,以便 Packer 插件正确过滤到所需的图像。

更多信息可以在文档中找到。

© www.soinside.com 2019 - 2024. All rights reserved.