Skip to content

Commit

Permalink
remove duplication in packer definition and allow for different OFED …
Browse files Browse the repository at this point in the history
…image size
  • Loading branch information
sjpb committed Mar 28, 2024
1 parent 81bcf36 commit 430af8a
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions packer/openstack.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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" {
Expand Down

0 comments on commit 430af8a

Please sign in to comment.