Skip to content

Commit 09a0261

Browse files
committed
failing - can't define standard and extra with different parameters!
1 parent 95f2e9b commit 09a0261

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

environments/.stackhpc/tofu/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module "cluster" {
7474
flavor: var.other_node_flavor
7575
}
7676
}
77-
compute = {
77+
compute = tomap({
7878
standard: { # NB: can't call this default!
7979
nodes: ["compute-0", "compute-1"]
8080
flavor: var.other_node_flavor
@@ -87,7 +87,7 @@ module "cluster" {
8787
#nodes: ["extra-0", "extra-1"]
8888
flavor: var.other_node_flavor
8989
}
90-
}
90+
})
9191

9292
volume_backed_instances = var.volume_backed_instances
9393

environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ module "compute" {
1414
environment_root = var.environment_root
1515

1616
# can be set for group, defaults to top-level value:
17-
image_id = lookup(each.value, "image_id", var.cluster_image_id)
18-
vnic_types = lookup(each.value, "vnic_types", var.vnic_types)
19-
volume_backed_instances = lookup(each.value, "volume_backed_instances", var.volume_backed_instances)
20-
root_volume_size = lookup(each.value, "root_volume_size", var.root_volume_size)
21-
gateway_ip = lookup(each.value, "gateway_ip", var.gateway_ip)
22-
nodename_template = lookup(each.value, "nodename_template", var.cluster_nodename_template)
17+
image_id = coalesce(each.value.image_id, var.cluster_image_id)
18+
vnic_types = coalesce(each.value.vnic_types, var.vnic_types)
19+
volume_backed_instances = coalesce(each.valuevolume_backed_instances, var.volume_backed_instances)
20+
root_volume_size = coalesce(each.value.root_volume_size, var.root_volume_size)
21+
gateway_ip = coalesce(each.value.gateway_ip, var.gateway_ip)
22+
nodename_template = coalesce(each.value.nodename_template, var.cluster_nodename_template)
2323

2424
# optionally set for group:
25-
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
26-
extra_volumes = lookup(each.value, "extra_volumes", {})
27-
compute_init_enable = lookup(each.value, "compute_init_enable", [])
28-
ignore_image_changes = lookup(each.value, "ignore_image_changes", false)
29-
match_ironic_node = lookup(each.value, "match_ironic_node", false)
30-
availability_zone = lookup(each.value, "availability_zone", "nova")
25+
networks = concat(var.cluster_networks, coalesce(each.value.extra_networks, []))
26+
extra_volumes = coalesce(each.value.extra_volumes, {})
27+
compute_init_enable = coalesce(each.value.compute_init_enable, [])
28+
ignore_image_changes = coalesce(each.value.ignore_image_changes, false)
29+
match_ironic_node = coalesce(each.value.match_ironic_node, false)
30+
availability_zone = coalesce(each.value.availability_zone, "nova")
3131

3232
# computed
3333
# not using openstack_compute_instance_v2.control.access_ip_v4 to avoid

environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/variables.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ variable "extra_volumes" {
5757
size: Size of volume in GB
5858
**NB**: The order in /dev is not guaranteed to match the mapping
5959
EOF
60-
type = any
60+
type = map(
61+
object({
62+
size = number
63+
})
64+
)
6165
default = {}
6266
}
6367

environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,7 @@ variable "cluster_image_id" {
7171
}
7272

7373
variable "compute" {
74-
type = object(
75-
object({
76-
nodes = list(string)
77-
flavor = string
78-
image_id = optional(string)
79-
extra_networks = list(map(string))
80-
vnic_types = map(string)
81-
compute_init_enable = list(string)
82-
ignore_image_changes = bool
74+
8375
description = <<-EOF
8476
Mapping defining homogenous groups of compute nodes. Groups are used
8577
in Slurm partition definitions.
@@ -109,6 +101,28 @@ variable "compute" {
109101
nodename_template: Overrides variable cluster_nodename_template
110102
EOF
111103
default = {}
104+
type = map( # i.e. arbitrary keys, values are of given type ...
105+
object({
106+
# Only need to specify required/optional *keys* here to
107+
# e.g. prevent missing/typos - value types are defined in
108+
# module inputs so don't repeat here
109+
nodes = any
110+
flavor = any
111+
112+
image_id = optional(any)
113+
extra_networks = optional(any)
114+
vnic_types = optional(any)
115+
compute_init_enable = optional(any)
116+
ignore_image_changes = optional(any)
117+
volume_backed_instances = optional(any)
118+
root_volume_size = optional(any)
119+
extra_volumes = optional(any)
120+
match_ironic_node = optional(any)
121+
availability_zone = optional(any)
122+
gateway_ip = optional(any)
123+
nodename_template = optional(any)
124+
})
125+
)
112126
}
113127

114128
variable "environment_root" {

0 commit comments

Comments
 (0)