Skip to content

Commit 72667d8

Browse files
committed
use github actions matrix w/ single packer build for ofed/non-ofed builds
1 parent 19be1be commit 72667d8

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

.github/workflows/arcus.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
concurrency: rcp-cloud-portal-demo # openstack project
88
jobs:
99
arcus:
10+
strategy:
11+
matrix:
12+
ofed_install: [false, true]
1013
runs-on: ubuntu-20.04
1114
defaults:
1215
run:
@@ -58,3 +61,4 @@ jobs:
5861
PACKER_LOG=1 packer build --on-error=ask -var-file=arcus.builder.pkrvars.hcl openstack.pkr.hcl
5962
env:
6063
OS_CLOUD: openstack
64+
PKR_VAR_ofed_install: ${{ matrix.ofed_install }}

openstack.pkr.hcl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
# $ PACKER_LOG=1 packer build --on-error=ask -var-file=<something>.pkrvars.hcl openstack.pkr.hcl
33

44
# "timestamp" template function replacement:s
5-
locals { timestamp = formatdate("YYMMDD-hhmm", timestamp())}
5+
locals {
6+
timestamp = formatdate("YYMMDD-hhmm", timestamp())
7+
# a lookup table to change image name with var.ofed_install:
8+
image_name_suffix = {
9+
true = "-ofed"
10+
false = ""
11+
}
12+
}
613

714
variable "source_image_name" {
815
type = string
@@ -20,7 +27,12 @@ variable "ssh_bastion_username" {
2027
}
2128

2229
variable "port_id" {
23-
type = string
30+
type = string # set by Terraform templating arcus.builder.pkrvars.hcl
31+
}
32+
33+
variable "ofed_install" {
34+
type = string # set by github CI via environment variables
35+
default = "false"
2436
}
2537

2638
source "openstack" "openhpc" {
@@ -33,31 +45,18 @@ source "openstack" "openhpc" {
3345
ssh_bastion_host = "128.232.222.183"
3446
ssh_bastion_username = "${var.ssh_bastion_username}"
3547
ssh_bastion_private_key_file = "~/.ssh/id_rsa"
48+
image_name = "${source.name}-${local.timestamp}${local.image_name_suffix[var.ofed_install]}.qcow2"
3649
ports = [var.port_id]
3750
}
3851

3952
build {
4053
source "source.openstack.openhpc" {
41-
name = "inbox"
42-
image_name = "openhpc-${local.timestamp}.qcow2"
43-
}
44-
45-
source "source.openstack.openhpc" {
46-
name = "ofed"
47-
image_name = "openhpc-${local.timestamp}-ofed.qcow2"
4854
}
4955

5056
provisioner "ansible" {
5157
playbook_file = "playbooks/build.yml" # can't use ansible FQCN here
5258
use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
53-
override = {
54-
inbox = {
55-
extra_arguments = ["-v"]
56-
}
57-
ofed = {
58-
extra_arguments = concat(["-v"], ["-e", "ofed_install=yes"])
59-
}
60-
}
59+
extra_arguments = ["-v", "-e", "ofed_install=${var.ofed_install}"]
6160
ansible_ssh_extra_args = ["-o ProxyCommand='ssh ${var.ssh_bastion_username }@${ var.ssh_bastion_host} -W %h:%p'"]
6261
}
6362

0 commit comments

Comments
 (0)