Skip to content

Commit ae9f7f9

Browse files
committed
fix source_image_name packer parse
1 parent c9ebf42 commit ae9f7f9

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

.github/workflows/fatimage.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ jobs:
3434
ANSIBLE_FORCE_COLOR: True
3535
OS_CLOUD: openstack
3636
CI_CLOUD: ${{ github.event.inputs.ci_cloud }}
37+
SOURCE_IMAGES_MAP: |
38+
{
39+
"RL8": {
40+
"openstack.openhpc": "rocky-latest-RL8",
41+
"openstack.openhpc-cuda": "rocky-latest-cuda-RL8"
42+
},
43+
"RL9": {
44+
"openstack.openhpc": "rocky-latest-RL9",
45+
"openstack.openhpc-cuda": "rocky-latest-cuda-RL9"
46+
}
47+
}
3748
3849
steps:
3950
- uses: actions/checkout@v2
@@ -77,17 +88,13 @@ jobs:
7788
cd packer/
7889
packer init .
7990
80-
if [[ "${{ matrix.build }}" == *"cuda"* ]]; then
81-
SOURCE_IMAGE_NAME="rocky-latest-cuda"
82-
else
83-
SOURCE_IMAGE_NAME="rocky-latest"
84-
fi
91+
SOURCE_IMAGE=${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version][matrix.build] }}
8592
8693
PACKER_LOG=1 packer build \
8794
-on-error=${{ vars.PACKER_ON_ERROR }} \
8895
-only=${{ matrix.build }} \
8996
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
90-
-var "source_image_name={\"${{ matrix.os_version }}\":\"${SOURCE_IMAGE_NAME}-${{ matrix.os_version }}\"}" \
97+
-var "source_image_name=${SOURCE_IMAGE}" \
9198
openstack.pkr.hcl
9299
env:
93100
PKR_VAR_os_version: ${{ matrix.os_version }}

.github/workflows/nightlybuild.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
ANSIBLE_FORCE_COLOR: True
3838
OS_CLOUD: openstack
3939
CI_CLOUD: ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
40+
SOURCE_IMAGES_MAP: |
41+
{
42+
"RL8": "Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2",
43+
"RL9": "Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2"
44+
}
45+
4046
steps:
4147
- uses: actions/checkout@v2
4248

@@ -79,10 +85,13 @@ jobs:
7985
cd packer/
8086
packer init .
8187
88+
SOURCE_IMAGE=${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version] }}
89+
8290
PACKER_LOG=1 packer build \
8391
-on-error=${{ vars.PACKER_ON_ERROR }} \
8492
-only=${{ matrix.build }} \
8593
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
94+
-var "source_image_name=${SOURCE_IMAGE}"
8695
openstack.pkr.hcl
8796
8897
env:

packer/openstack.pkr.hcl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,8 @@ variable "os_version" {
4747

4848
# Must supply either source_image_name or source_image_id
4949
variable "source_image_name" {
50-
type = map(string)
51-
description = "name of source image, keyed from var.os_version"
52-
default = {
53-
RL8: "Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2"
54-
RL9: "Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2"
55-
}
50+
type = string
51+
description = "name of source image"
5652
}
5753

5854
variable "source_image" {
@@ -174,7 +170,7 @@ source "openstack" "openhpc" {
174170

175171
# Input image:
176172
source_image = "${var.source_image[var.os_version]}"
177-
source_image_name = "${var.source_image_name[var.os_version]}" # NB: must already exist in OpenStack
173+
source_image_name = "${var.source_image_name}" # NB: must already exist in OpenStack
178174

179175
# SSH:
180176
ssh_username = var.ssh_username

0 commit comments

Comments
 (0)