From 430af8ae13f10853e6063ee935cb8231b4d69128 Mon Sep 17 00:00:00 2001 From: Steve Brasier Date: Thu, 28 Mar 2024 14:40:14 +0000 Subject: [PATCH] remove duplication in packer definition and allow for different OFED image size --- packer/openstack.pkr.hcl | 55 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/packer/openstack.pkr.hcl b/packer/openstack.pkr.hcl index 68abb6b7f..0db3591f7 100644 --- a/packer/openstack.pkr.hcl +++ b/packer/openstack.pkr.hcl @@ -130,6 +130,11 @@ variable "volume_size" { default = null # When not specified use the size of the builder instance root disk } +variable "volume_size_ofed" { + type = number + default = null # When not specified use the size of the builder instance root disk +} + variable "image_disk_format" { type = string default = null # When not specified use the image default @@ -141,22 +146,32 @@ variable "metadata" { } source "openstack" "openhpc" { - flavor = "${var.flavor}" - volume_size = "${var.volume_size}" - use_blockstorage_volume = "${var.use_blockstorage_volume}" + # Build VM: + flavor = var.flavor + use_blockstorage_volume = var.use_blockstorage_volume volume_type = var.volume_type - image_disk_format = "${var.image_disk_format}" - metadata = "${var.metadata}" - networks = "${var.networks}" - ssh_username = "${var.ssh_username}" + metadata = var.metadata + networks = var.networks + floating_ip_network = var.floating_ip_network + security_groups = var.security_groups + + # Input image: + source_image = "${var.fatimage_source_image[var.os_version]}" + source_image_name = "${var.fatimage_source_image_name[var.os_version]}" # NB: must already exist in OpenStack + + # SSH: + ssh_username = var.ssh_username ssh_timeout = "20m" - ssh_private_key_file = "${var.ssh_private_key_file}" # TODO: doc same requirements as for qemu build? - ssh_keypair_name = "${var.ssh_keypair_name}" # TODO: doc this - ssh_bastion_host = "${var.ssh_bastion_host}" - ssh_bastion_username = "${var.ssh_bastion_username}" - ssh_bastion_private_key_file = "${var.ssh_bastion_private_key_file}" - security_groups = "${var.security_groups}" - image_visibility = "${var.image_visibility}" + ssh_private_key_file = var.ssh_private_key_file + ssh_keypair_name = var.ssh_keypair_name # TODO: doc this + ssh_bastion_host = var.ssh_bastion_host + ssh_bastion_username = var.ssh_bastion_username + ssh_bastion_private_key_file = var.ssh_bastion_private_key_file + + # Output image: + image_disk_format = var.image_disk_format + image_visibility = var.image_visibility + image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}" } # "fat" image builds: @@ -165,19 +180,13 @@ build { # non-OFED: source "source.openstack.openhpc" { name = "openhpc" - floating_ip_network = "${var.floating_ip_network}" - source_image = "${var.fatimage_source_image[var.os_version]}" - source_image_name = "${var.fatimage_source_image_name[var.os_version]}" # NB: must already exist in OpenStack - image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}" # similar to name from slurm_image_builder + volume_size = var.volume_size } # OFED: source "source.openstack.openhpc" { - name = "openhpc-ofed" # this is the only difference from the above - floating_ip_network = "${var.floating_ip_network}" - source_image = "${var.fatimage_source_image[var.os_version]}" - source_image_name = "${var.fatimage_source_image_name[var.os_version]}" - image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}" + name = "openhpc-ofed" + volume_size = var.volume_size_ofed } provisioner "ansible" {