From 2a6b25fd76a9e940cc30bef6222e43e5860c339a Mon Sep 17 00:00:00 2001 From: Balasankar 'Balu' C Date: Wed, 30 Nov 2022 01:03:10 +0000 Subject: [PATCH] Generate packer manifests and store them as artifacts For each AMI build, generate a manifest file with details of the built artifacts, like AMI IDs. This information can be then used for any release documentation we might do in the future. Related https://gitlab.com/gitlab-org/distribution/team-tasks/-/issues/460 Signed-off-by: Balasankar "Balu" C --- .gitignore | 2 ++ gitlab-ci-config/dev-gitlab-org.yml | 3 +++ support/packer/ce-arm64.pkr.hcl | 6 ++++++ support/packer/ce.pkr.hcl | 6 ++++++ support/packer/ee-arm64.pkr.hcl | 6 ++++++ support/packer/ee-premium.pkr.hcl | 6 ++++++ support/packer/ee-ultimate.pkr.hcl | 6 ++++++ support/packer/ee.pkr.hcl | 6 ++++++ support/packer/packer_ami.sh | 3 +++ 9 files changed, 44 insertions(+) diff --git a/.gitignore b/.gitignore index 6cf0c404e..e9eb5b563 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ spec/examples.txt coverage/ junit_rspec.xml + +support/packer/manifests diff --git a/gitlab-ci-config/dev-gitlab-org.yml b/gitlab-ci-config/dev-gitlab-org.yml index ead04cfbb..839988285 100644 --- a/gitlab-ci-config/dev-gitlab-org.yml +++ b/gitlab-ci-config/dev-gitlab-org.yml @@ -239,6 +239,9 @@ tags: - docker-builder cache: !reference [.tag-cache] + artifacts: + paths: + - support/packer/manifests needs: - Ubuntu-20.04 retry: 1 diff --git a/support/packer/ce-arm64.pkr.hcl b/support/packer/ce-arm64.pkr.hcl index c6788d9b0..4b10328aa 100644 --- a/support/packer/ce-arm64.pkr.hcl +++ b/support/packer/ce-arm64.pkr.hcl @@ -125,4 +125,10 @@ build { script = "update-script-ce.sh" } + post-processor "manifest" { + output = "manifests/ce-arm64-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab CE ${var.version} (ARM64)" + } + } } diff --git a/support/packer/ce.pkr.hcl b/support/packer/ce.pkr.hcl index 47104375a..5c7c34de5 100644 --- a/support/packer/ce.pkr.hcl +++ b/support/packer/ce.pkr.hcl @@ -125,4 +125,10 @@ build { script = "update-script-ce.sh" } + post-processor "manifest" { + output = "manifests/ce-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab CE ${var.version}" + } + } } diff --git a/support/packer/ee-arm64.pkr.hcl b/support/packer/ee-arm64.pkr.hcl index a356abddb..2d7c12c80 100644 --- a/support/packer/ee-arm64.pkr.hcl +++ b/support/packer/ee-arm64.pkr.hcl @@ -122,4 +122,10 @@ build { script = "update-script-ee.sh" } + post-processor "manifest" { + output = "manifests/ee-arm64-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab EE ${var.version} (ARM64)" + } + } } diff --git a/support/packer/ee-premium.pkr.hcl b/support/packer/ee-premium.pkr.hcl index d5ae48ee7..1775afbe0 100644 --- a/support/packer/ee-premium.pkr.hcl +++ b/support/packer/ee-premium.pkr.hcl @@ -121,4 +121,10 @@ build { script = "update-script-ee-premium.sh" } + post-processor "manifest" { + output = "manifests/ee-premium-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab EE ${var.version} Premium" + } + } } diff --git a/support/packer/ee-ultimate.pkr.hcl b/support/packer/ee-ultimate.pkr.hcl index 5d14440e0..3252b79ad 100644 --- a/support/packer/ee-ultimate.pkr.hcl +++ b/support/packer/ee-ultimate.pkr.hcl @@ -121,4 +121,10 @@ build { script = "update-script-ee-ultimate.sh" } + post-processor "manifest" { + output = "manifests/ee-ultimate-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab EE ${var.version} Ultimate" + } + } } diff --git a/support/packer/ee.pkr.hcl b/support/packer/ee.pkr.hcl index ba16c25be..1b33179a8 100644 --- a/support/packer/ee.pkr.hcl +++ b/support/packer/ee.pkr.hcl @@ -122,4 +122,10 @@ build { script = "update-script-ee.sh" } + post-processor "manifest" { + output = "manifests/ee-manifest.json" + custom_data = { + name: "${var.ami_prefix}GitLab EE ${var.version}" + } + } } diff --git a/support/packer/packer_ami.sh b/support/packer/packer_ami.sh index 76cb9a759..e0f39105a 100755 --- a/support/packer/packer_ami.sh +++ b/support/packer/packer_ami.sh @@ -13,4 +13,7 @@ PACKER_PATH=$(pwd)/support/packer cd $PACKER_PATH +# To store the post processor manifest file +mkdir -p manifests + packer build -var "aws_access_key=$AWS_AMI_ACCESS_KEY_ID" -var "aws_secret_key=$AWS_AMI_SECRET_ACCESS_KEY" -var "version=$VERSION" -var "download_url=$DOWNLOAD_URL" -var "license_file=$EE_LICENSE_FILE" $PACKER_PATH/$TYPE.pkr.hcl