diff --git a/environments/.stackhpc/tofu/cluster_image.auto.tfvars.json b/environments/.stackhpc/tofu/cluster_image.auto.tfvars.json index f9e568c3f..0afb56887 100644 --- a/environments/.stackhpc/tofu/cluster_image.auto.tfvars.json +++ b/environments/.stackhpc/tofu/cluster_image.auto.tfvars.json @@ -1,6 +1,10 @@ { - "cluster_image": { - "RL8": "openhpc-RL8-250102-1138-77cfc703", - "RL9": "openhpc-RL9-250102-1139-77cfc703" + "cluster_image_names": { + "RL8": { + "default": "openhpc-RL8-250102-1138-77cfc703" + }, + "RL9": { + "default": "openhpc-RL9-250102-1139-77cfc703" + } } } diff --git a/environments/.stackhpc/tofu/main.tf b/environments/.stackhpc/tofu/main.tf index ac57f503a..31cdb8157 100644 --- a/environments/.stackhpc/tofu/main.tf +++ b/environments/.stackhpc/tofu/main.tf @@ -1,3 +1,4 @@ + # This terraform configuration uses the "skeleton" terraform, so that is checked by CI. terraform { @@ -25,9 +26,9 @@ variable "os_version" { default = "RL9" } -variable "cluster_image" { - description = "single image for all cluster nodes, keyed by os_version - a convenience for CI" - type = map(string) +variable "cluster_image_names" { + description = "image *names* keyed by os_version, for CI" + type = map(map(string)) } variable "cluster_net" {} @@ -58,8 +59,10 @@ variable "k3s_token" { type = string } -data "openstack_images_image_v2" "cluster" { - name = var.cluster_image[var.os_version] +data "openstack_images_image_v2" "cluster_images" { + for_each = var.cluster_image_names[var.os_version] + + name = each.value most_recent = true } @@ -71,7 +74,7 @@ module "cluster" { cluster_subnet = var.cluster_subnet vnic_type = var.vnic_type key_pair = "slurm-app-ci" - cluster_image_id = data.openstack_images_image_v2.cluster.id + cluster_image_ids = {for key, img in data.openstack_images_image_v2.cluster_images: key => img.id} control_node_flavor = var.control_node_flavor k3s_token = var.k3s_token diff --git a/environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf b/environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf index 14c728a5a..9dc0e05c7 100644 --- a/environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf +++ b/environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf @@ -10,7 +10,7 @@ module "compute" { cluster_subnet_id = data.openstack_networking_subnet_v2.cluster_subnet.id flavor = each.value.flavor - image_id = lookup(each.value, "image_id", var.cluster_image_id) + image_id = lookup(var.cluster_image_ids, each.key, var.cluster_image_ids["default"]) vnic_type = lookup(each.value, "vnic_type", var.vnic_type) vnic_profile = lookup(each.value, "vnic_profile", var.vnic_profile) key_pair = var.key_pair diff --git a/environments/skeleton/{{cookiecutter.environment}}/tofu/nodes.tf b/environments/skeleton/{{cookiecutter.environment}}/tofu/nodes.tf index 8ea8cabcb..bf5900324 100644 --- a/environments/skeleton/{{cookiecutter.environment}}/tofu/nodes.tf +++ b/environments/skeleton/{{cookiecutter.environment}}/tofu/nodes.tf @@ -45,13 +45,13 @@ resource "openstack_compute_instance_v2" "control" { for_each = toset(["control"]) name = "${var.cluster_name}-${each.key}" - image_id = var.cluster_image_id + image_id = var.cluster_image_ids["default"] flavor_name = var.control_node_flavor key_pair = var.key_pair # root device: block_device { - uuid = var.cluster_image_id + uuid = var.cluster_image_ids["default"] source_type = "image" destination_type = var.volume_backed_instances ? "volume" : "local" volume_size = var.volume_backed_instances ? var.root_volume_size : null @@ -102,14 +102,14 @@ resource "openstack_compute_instance_v2" "login" { for_each = var.login_nodes name = "${var.cluster_name}-${each.key}" - image_id = var.cluster_image_id + image_id = var.cluster_image_ids["default"] flavor_name = each.value key_pair = var.key_pair dynamic "block_device" { for_each = var.volume_backed_instances ? [1]: [] content { - uuid = var.cluster_image_id + uuid = var.cluster_image_ids["default"] source_type = "image" destination_type = "volume" volume_size = var.root_volume_size diff --git a/environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf b/environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf index 0f5eefa18..2e71e0c5c 100644 --- a/environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf +++ b/environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf @@ -34,9 +34,13 @@ variable "login_nodes" { description = "Mapping defining login nodes: key -> (str) nodename suffix, value -> (str) flavor name" } -variable "cluster_image_id" { - type = string - description = "ID of default image for the cluster" +variable "cluster_image_ids" { + type = map(string) + description = <<-EOF + Mapping of UUIDs defining images for the cluster. Valid keys are: + - "default": required, defines default image for cluster + - any key from "compute" variable, to define different images for compute node groups + EOF } variable "compute" { @@ -49,7 +53,6 @@ variable "compute" { nodes: List of node names flavor: String flavor name Optional: - image_id: Overrides variable cluster_image_id vnic_type: Overrides variable vnic_type vnic_profile: Overrides variable vnic_profile EOF