Skip to content

Convert packer scripts to use HCL instead of JSON

Andrew Patterson requested to merge 6505-convert-packer-scripts-to-use-hcl into master

What does this MR do?

Use HCL instead of JSON for scripts that create AWS AMIs.

Related issues

Closes #6505 (closed) Related #7264

Test plan

Local build instructions

  1. Check out branch.

  2. cd support/packer.

  3. Pull debian_packer image:

    docker pull registry.gitlab.com/gitlab-org/gitlab-omnibus-builder/debian_packer:3.9.0
  4. Start container.

    docker run --name debian_packer -v <branch dir>:/omnibus-gitlab -it registry.gitlab.com/gitlab-org/gitlab-omnibus-builder/debian_packer:3.9.0 bash 
  5. Get AWS credentials for my account in our AWS staging account (gitlab-top) and export them as variables AWS_AMI_ACCESS_KEY_ID and AWS_AMI_SECRET_ACCESS_KEY.

    export AWS_AMI_ACCESS_KEY_ID=<AWS PAT public key>
    export AWS_AMI_SECRET_ACCESS_KEY=<AWS PAT secret key>
  6. For each *.pkr.hcl file in support/packer:

    packer build  -var "aws_access_key=$AWS_AMI_ACCESS_KEY_ID" -var "aws_secret_key=$AWS_AMI_SECRET_ACCESS_KEY" -var "version=99.99.99" -var "download_url=https://downloads-packages.s3.amazonaws.com/ubuntu-focal[_aarch64]/gitlab-ee_15.<latest version>-ee.0_<amd64|arm64>.deb" -var "ami_prefix=<FirstName> <Last intial> Test " [-var "license_file="<contents of license>"] -var "ami_regions=[]" <image>.pkr.hcl

    Note: You should probably use an intermediate shell variable to hold the license file contents, i.e.,

    GITLAB_LICENSE=eyJkYXRhIjoicEoy...
    packer build ... -var "license_file=$GITLAB_LICENSE" ...

Tests

  • Build all AMIs locally. Make sure Name, Description, Version, Tag, and architecture are correct. Check for license if applicable.
    • ce-arm64
    • ce
    • ee-arm64
    • ee-premium
    • ee-ultimate
    • ee
  • Create instance and perform basic functionality test (create user, create project, create issue)
    • ce-arm64
    • ce
    • ee-arm64
    • ee-premium
    • ee-ultimate
    • ee

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • Pipeline is green on the dev.gitlab.org mirror for this branch if the change is touching anything besides documentation or internal cookbooks. Please note that feature branches are not automatically mirrored to dev.gitlab.org, and should be manually pushed whenever necessary.
  • trigger-package has a green pipeline running against latest commit

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for the GitLab Chart opened
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Andrew Patterson

Merge request reports