From f91a22900e8eaf31858d97814f5d8640ae414305 Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 17 Jul 2023 12:55:36 -0400 Subject: [PATCH 1/5] Update Packer version to 1.9.1 --- packer/README.md | 2 +- packer/cloudbuild.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packer/README.md b/packer/README.md index ad1159316..f99dc4fa7 100644 --- a/packer/README.md +++ b/packer/README.md @@ -23,7 +23,7 @@ gcloud builds submit . > **Advanced builder building:** To specify a particular version of packer, provide the packer version > number, and the checksum of that version's zip archive, as Cloud Build [substitutions][substitutions]: > ``` -> gcloud builds submit --substitutions=_PACKER_VERSION=1.7.8,_PACKER_VERSION_SHA256SUM=8a94b84542d21b8785847f4cccc8a6da4c7be5e16d4b1a2d0a5f7ec5532faec0 . +> gcloud builds submit --substitutions=_PACKER_VERSION=1.9.1,_PACKER_VERSION_SHA256SUM=793ed62255b9e572eda0c77d2a770f5fde501314b7598320786f1e51feb260d6 . > ``` [substitutions]: https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values#using_user-defined_substitutions diff --git a/packer/cloudbuild.yaml b/packer/cloudbuild.yaml index 9f1d374a0..89b82e554 100644 --- a/packer/cloudbuild.yaml +++ b/packer/cloudbuild.yaml @@ -1,7 +1,7 @@ # In this directory, run the following command to build this builder. # $ gcloud builds submit . --config=cloudbuild.yaml -# See docs at https://www.packer.io/docs/install/index.html +# See docs at https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli steps: - name: 'gcr.io/cloud-builders/wget' args: ["https://releases.hashicorp.com/packer/${_PACKER_VERSION}/packer_${_PACKER_VERSION}_linux_amd64.zip"] @@ -12,8 +12,8 @@ steps: '--build-arg', 'PACKER_VERSION_SHA256SUM=${_PACKER_VERSION_SHA256SUM}', '.'] substitutions: - _PACKER_VERSION: 1.7.8 - _PACKER_VERSION_SHA256SUM: 8a94b84542d21b8785847f4cccc8a6da4c7be5e16d4b1a2d0a5f7ec5532faec0 + _PACKER_VERSION: 1.9.1 + _PACKER_VERSION_SHA256SUM: 793ed62255b9e572eda0c77d2a770f5fde501314b7598320786f1e51feb260d6 images: - 'gcr.io/$PROJECT_ID/packer:latest' From 399ab3a7f7766438d6bc6db52172caa4e004070d Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 17 Jul 2023 12:55:58 -0400 Subject: [PATCH 2/5] Update build image to supported version of Alpine --- packer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/Dockerfile b/packer/Dockerfile index 552da422d..07b695416 100644 --- a/packer/Dockerfile +++ b/packer/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.14 AS build +FROM alpine:3.18 AS build ARG PACKER_VERSION ARG PACKER_VERSION_SHA256SUM From f2f7833629e9299789acaf0ba35e2c1f6a717e35 Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 17 Jul 2023 12:56:40 -0400 Subject: [PATCH 3/5] Fix the source image family in the example --- packer/examples/gce/build.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/examples/gce/build.pkr.hcl b/packer/examples/gce/build.pkr.hcl index 4b4a90015..b8cb1780e 100644 --- a/packer/examples/gce/build.pkr.hcl +++ b/packer/examples/gce/build.pkr.hcl @@ -12,7 +12,7 @@ variable "builder_sa" { source "googlecompute" "test-image" { project_id = var.project_id - source_image_family = "ubuntu-2104" + source_image_family = "ubuntu-2204-lts" zone = var.zone image_description = "Created with Packer from Cloudbuild" ssh_username = "root" From 553411fd1d09614b608fcf0842ceb98e46d3dccc Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 17 Jul 2023 13:11:42 -0400 Subject: [PATCH 4/5] Add packer block and init step Rationale: a future version of Packer will remove bundled plugins from the `packer` binary. The recommended approach is to use the `required_plugins` block and run `packer init`. --- packer/examples/gce/build.pkr.hcl | 9 +++++++++ packer/examples/gce/cloudbuild.yaml | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/packer/examples/gce/build.pkr.hcl b/packer/examples/gce/build.pkr.hcl index b8cb1780e..a0f6faf25 100644 --- a/packer/examples/gce/build.pkr.hcl +++ b/packer/examples/gce/build.pkr.hcl @@ -1,3 +1,12 @@ +packer { + required_plugins { + googlecompute = { + version = ">= 1.1.1" + source = "github.com/hashicorp/googlecompute" + } + } +} + variable "project_id" { type = string } diff --git a/packer/examples/gce/cloudbuild.yaml b/packer/examples/gce/cloudbuild.yaml index dced1ee34..c89a40698 100644 --- a/packer/examples/gce/cloudbuild.yaml +++ b/packer/examples/gce/cloudbuild.yaml @@ -4,6 +4,11 @@ # # See README.md for invocation instructions. steps: +- name: 'gcr.io/$PROJECT_ID/packer' + args: + - init + - -var-file=variables.pkrvars.hcl + - build.pkr.hcl - name: 'gcr.io/$PROJECT_ID/packer' args: - build From 016b9d9ce1390c4558828a9639692567266291a1 Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 17 Jul 2023 13:12:01 -0400 Subject: [PATCH 5/5] Docs updates Update some links and product references --- packer/README.md | 13 +++++++------ packer/examples/gce/README.md | 4 ++-- packer/examples/gce/build.pkr.hcl | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packer/README.md b/packer/README.md index f99dc4fa7..b679046ee 100644 --- a/packer/README.md +++ b/packer/README.md @@ -1,15 +1,15 @@ -# Packer +# HashiCorp Packer -This build step invokes `packer` commands in [Google Cloud Build][cloud-build]. +This build step invokes [HashiCorp Packer][packer] in [Google Cloud Build][cloud-build]. -Arguments passed to this builder will be passed to [`packer`][packer] directly, allowing callers to +Arguments passed to this builder will be passed to `packer` directly, allowing callers to run [any Packer command][packer-commands]. [cloud-build]: https://cloud.google.com/cloud-build [packer]: https://www.packer.io -[packer-commands]: https://www.packer.io/docs/commands +[packer-commands]: https://developer.hashicorp.com/packer/docs/commands ## Building this Builder @@ -20,8 +20,9 @@ your project. Run the following command in this directory: gcloud builds submit . ``` -> **Advanced builder building:** To specify a particular version of packer, provide the packer version -> number, and the checksum of that version's zip archive, as Cloud Build [substitutions][substitutions]: +> **Advanced builder building:** To specify a particular version of Packer, provide the Packer version +> number and the checksum of that version's linux/amd64 zip archive as Cloud Build +> [substitutions][substitutions]: > ``` > gcloud builds submit --substitutions=_PACKER_VERSION=1.9.1,_PACKER_VERSION_SHA256SUM=793ed62255b9e572eda0c77d2a770f5fde501314b7598320786f1e51feb260d6 . > ``` diff --git a/packer/examples/gce/README.md b/packer/examples/gce/README.md index 82bf5a152..2001af61b 100644 --- a/packer/examples/gce/README.md +++ b/packer/examples/gce/README.md @@ -1,8 +1,8 @@ # Packer GCE build -This directory contains an example that creates a GCE image using `packer`. +This directory contains an example that creates a GCE image using HashiCorp Packer. -Example Packer build is using [HCL2 syntax](https://www.packer.io/guides/hcl) and creates +Example Packer build is using [HCL2 syntax](https://developer.hashicorp.com/packer/guides/hcl) and creates GCE image basing on Ubuntu Linux. **Note**: This example assumes that you have built the `packer` build step and pushed it to diff --git a/packer/examples/gce/build.pkr.hcl b/packer/examples/gce/build.pkr.hcl index a0f6faf25..0f4ab89e9 100644 --- a/packer/examples/gce/build.pkr.hcl +++ b/packer/examples/gce/build.pkr.hcl @@ -23,7 +23,7 @@ source "googlecompute" "test-image" { project_id = var.project_id source_image_family = "ubuntu-2204-lts" zone = var.zone - image_description = "Created with Packer from Cloudbuild" + image_description = "Created with HashiCorp Packer from Cloudbuild" ssh_username = "root" tags = ["packer"] impersonate_service_account = var.builder_sa