Skip to content

Commit 430af8a

Browse files
committed
remove duplication in packer definition and allow for different OFED image size
1 parent 81bcf36 commit 430af8a

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

packer/openstack.pkr.hcl

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ variable "volume_size" {
130130
default = null # When not specified use the size of the builder instance root disk
131131
}
132132

133+
variable "volume_size_ofed" {
134+
type = number
135+
default = null # When not specified use the size of the builder instance root disk
136+
}
137+
133138
variable "image_disk_format" {
134139
type = string
135140
default = null # When not specified use the image default
@@ -141,22 +146,32 @@ variable "metadata" {
141146
}
142147

143148
source "openstack" "openhpc" {
144-
flavor = "${var.flavor}"
145-
volume_size = "${var.volume_size}"
146-
use_blockstorage_volume = "${var.use_blockstorage_volume}"
149+
# Build VM:
150+
flavor = var.flavor
151+
use_blockstorage_volume = var.use_blockstorage_volume
147152
volume_type = var.volume_type
148-
image_disk_format = "${var.image_disk_format}"
149-
metadata = "${var.metadata}"
150-
networks = "${var.networks}"
151-
ssh_username = "${var.ssh_username}"
153+
metadata = var.metadata
154+
networks = var.networks
155+
floating_ip_network = var.floating_ip_network
156+
security_groups = var.security_groups
157+
158+
# Input image:
159+
source_image = "${var.fatimage_source_image[var.os_version]}"
160+
source_image_name = "${var.fatimage_source_image_name[var.os_version]}" # NB: must already exist in OpenStack
161+
162+
# SSH:
163+
ssh_username = var.ssh_username
152164
ssh_timeout = "20m"
153-
ssh_private_key_file = "${var.ssh_private_key_file}" # TODO: doc same requirements as for qemu build?
154-
ssh_keypair_name = "${var.ssh_keypair_name}" # TODO: doc this
155-
ssh_bastion_host = "${var.ssh_bastion_host}"
156-
ssh_bastion_username = "${var.ssh_bastion_username}"
157-
ssh_bastion_private_key_file = "${var.ssh_bastion_private_key_file}"
158-
security_groups = "${var.security_groups}"
159-
image_visibility = "${var.image_visibility}"
165+
ssh_private_key_file = var.ssh_private_key_file
166+
ssh_keypair_name = var.ssh_keypair_name # TODO: doc this
167+
ssh_bastion_host = var.ssh_bastion_host
168+
ssh_bastion_username = var.ssh_bastion_username
169+
ssh_bastion_private_key_file = var.ssh_bastion_private_key_file
170+
171+
# Output image:
172+
image_disk_format = var.image_disk_format
173+
image_visibility = var.image_visibility
174+
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
160175
}
161176

162177
# "fat" image builds:
@@ -165,19 +180,13 @@ build {
165180
# non-OFED:
166181
source "source.openstack.openhpc" {
167182
name = "openhpc"
168-
floating_ip_network = "${var.floating_ip_network}"
169-
source_image = "${var.fatimage_source_image[var.os_version]}"
170-
source_image_name = "${var.fatimage_source_image_name[var.os_version]}" # NB: must already exist in OpenStack
171-
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}" # similar to name from slurm_image_builder
183+
volume_size = var.volume_size
172184
}
173185

174186
# OFED:
175187
source "source.openstack.openhpc" {
176-
name = "openhpc-ofed" # this is the only difference from the above
177-
floating_ip_network = "${var.floating_ip_network}"
178-
source_image = "${var.fatimage_source_image[var.os_version]}"
179-
source_image_name = "${var.fatimage_source_image_name[var.os_version]}"
180-
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
188+
name = "openhpc-ofed"
189+
volume_size = var.volume_size_ofed
181190
}
182191

183192
provisioner "ansible" {

0 commit comments

Comments
 (0)