From 0a053813d19bfd456eb5da5f71baf088646a916c Mon Sep 17 00:00:00 2001 From: Steve Brasier Date: Tue, 5 Nov 2024 21:23:50 +0000 Subject: [PATCH] simplify build spec --- .github/workflows/nightlybuild.yml | 36 +++++++++++++----------------- packer/openstack.pkr.hcl | 8 +++---- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 2da602d5..3357d307 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -17,31 +17,28 @@ jobs: openstack: name: openstack-imagebuild concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.source_image.name }}-${{ matrix.inventory_groups.label }} # to branch/PR + OS + build + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }} cancel-in-progress: true runs-on: ubuntu-22.04 strategy: fail-fast: false # allow other matrix jobs to continue even if one fails matrix: - source_image: - - label: RL8 - name: Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2 - - label: RL9 - name: Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2 - inventory_groups: - - label: ofed - list: 'update,ofed' - - label: cuda - list: 'update,ofed,cuda' - exclude: - - source_image: {label: RL8} - inventory_groups: {label: cuda} + builds: + - label: RL8-ofed + source_image_name: Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2 + inventory_groups: 'update,ofed' + - label: RL9-ofed + source_image_name: Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2 + inventory_groups: 'update,ofed' + - label: RL9-cuda + source_image_name: Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2 + inventory_groups: 'update,ofed,cuda' env: ANSIBLE_FORCE_COLOR: True OS_CLOUD: openstack CI_CLOUD: ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }} # set the image suffix to -latest for cron jobs or a branch name if manually-triggered - IMAGE_NAME_SUFFIX: ${{ github.event_name == 'schedule' && 'latest' || github.ref_name }} + IMAGE_SUFFIX: ${{ github.event_name == 'schedule' && 'latest' || github.ref_name }} steps: - uses: actions/checkout@v2 @@ -88,14 +85,13 @@ jobs: packer build \ -on-error=${{ vars.PACKER_ON_ERROR }} \ -var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \ - -var source_image_name=${{ matrix.source_image.name }} \ - -var image_name=rocky-${{ matrix.source_image.label }}-${{ matrix.inventory_groups.label }} \ - -var image_name_suffix=${{ env.IMAGE_NAME_SUFFIX }} \ - -var inventory_groups=${{ matrix.inventory_groups.list }} \ + -var source_image_name=${{ matrix.source_image_name }} \ + -var image_name=${{ matrix.label }} \ + -var image_version=${{ env.IMAGE_SUFFIX }} \ + -var inventory_groups=${{ matrix.inventory_groups }} \ openstack.pkr.hcl env: PACKER_LOG: '1' - - name: Get created image names from manifest id: manifest diff --git a/packer/openstack.pkr.hcl b/packer/openstack.pkr.hcl index 6fa9e6c7..6c1f7d12 100644 --- a/packer/openstack.pkr.hcl +++ b/packer/openstack.pkr.hcl @@ -23,7 +23,7 @@ data "git-commit" "cwd-head" { } locals { git_commit = data.git-commit.cwd-head.hash timestamp = formatdate("YYMMDD-hhmm", timestamp()) - image_name_suffix = var.image_name_suffix == "" ? "${local.timestamp}-${substr(local.git_commit, 0, 8)}" : var.image_name_suffix + image_version = var.image_version == "" ? "${local.timestamp}-${substr(local.git_commit, 0, 8)}" : var.image_version } # Path pointing to root of repository - automatically set by environment variable PKR_VAR_repo_root @@ -140,7 +140,7 @@ variable "metadata" { variable "inventory_groups" { type = string description = "comma-separated list of inventory groups, in addition to 'builder'" - default = '' + default = "" } # variable "groups" { @@ -161,7 +161,7 @@ variable "image_name" { default = "openhpc" } -variable "image_name_suffix" { +variable "image_version" { type = string description = "Suffix for built image names. If not supplied a timestamp+git commit is used" default = "" @@ -202,7 +202,7 @@ build { source "source.openstack.openhpc" { name = "rocky-latest" - image_name = "${var.image_name}-${local.image_name_suffix}" + image_name = "${var.image_name}-${local.image_version}" } provisioner "ansible" {