Skip to content

Commit

Permalink
simplify build spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpb committed Nov 5, 2024
1 parent fa16e2d commit 0a05381
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
36 changes: 16 additions & 20 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packer/openstack.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand All @@ -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 = ""
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 0a05381

Please sign in to comment.