【问题标题】:Create image with Packer Google Compute Builder but without project users baked in (cloud-init)使用 Packer Google Compute Builder 创建映像,但没有嵌入项目用户(cloud-init)
【发布时间】:2022-01-20 17:46:52
【问题描述】:

我正在使用 Google Compute Builder 创建打包程序映像:

source "googlecompute" "github-runner" {
  image_name          = "github-runner-${replace(var.runner_version, ".", "-")}-v${var.custom_version}"
  image_family        = "github-runner"
  project_id          = "xxx"
  source_image_family = "ubuntu-2004-lts"
  ssh_username        = "packer"
  use_internal_ip     = true
  zone                = "europe-west4-c"
}

build {
  sources = [
    "source.googlecompute.github-runner"
  ]
}

但是,由于 cloud-init,所有项目用户都在构建器 VM 中进行配置,因此在最终映像中进行配置。

是否有任何选项可以跳过在构建器 VM 上创建项目的用户?

【问题讨论】:

标签: google-cloud-platform google-compute-engine packer cloud-init hashicorp-packer


【解决方案1】:

所以解决方案是将block-project-ssh-keys = "true" 添加到元数据中。最终声明:

source "googlecompute" "github-runner" {
  image_name          = "github-runner-${replace(var.runner_version, ".", "-")}-v${var.custom_version}"
  image_family        = "github-runner"
  project_id          = "xxx"
  source_image_family = "ubuntu-2004-lts"
  ssh_username        = "packer"
  use_internal_ip     = true
  zone                = "europe-west4-c"
  metadata = {
    block-project-ssh-keys = "true"
  }
}

build {
  sources = [
    "source.googlecompute.github-runner"
  ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-09
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    相关资源
    最近更新 更多