@@ -52,7 +52,8 @@ variable "login" {
52
52
be useful for e.g. separating nodes for ssh and Open Ondemand usage, or
53
53
to define login nodes with different capabilities such as high-memory.
54
54
55
- Keys are names of groups.
55
+ Keys are names of groups, and cannot be 'login', 'compute', 'control', or
56
+ keys in the compute or additional_nodegroups variables.
56
57
Values are a mapping as follows:
57
58
58
59
Required:
@@ -88,6 +89,25 @@ variable "login" {
88
89
EOF
89
90
90
91
type = any
92
+ validation {
93
+ condition = length (setintersection (keys (var. login ), [" login" , " compute" , " control" ])) == 0
94
+ error_message = <<- EOF
95
+ Login nodegroup names cannot be 'login', 'compute' or 'control'. Invalid var.login key(s): ${ join (" , " , setintersection (keys (var. login ), [" login" , " compute" , " control" ]))} .
96
+ EOF
97
+ }
98
+ validation {
99
+ condition = length (distinct (concat (keys (var. login ), keys (var. compute ), keys (var. additional_nodegroups )))) == length (concat (keys (var. login ), keys (var. compute ), keys (var. additional_nodegroups )))
100
+ error_message = <<- EOF
101
+ Nodegroup names must be unique. Shared key(s) found in variables login, compute and/or additional_nodegroups: ${
102
+ join (" , " , setunion (
103
+ setintersection (keys (var. login ), keys (var. compute )),
104
+ setintersection (keys (var. compute ), keys (var. additional_nodegroups )),
105
+ setintersection (keys (var. additional_nodegroups ), keys (var. login ))
106
+ ))
107
+ }
108
+ EOF
109
+
110
+ }
91
111
}
92
112
93
113
variable "cluster_image_id" {
@@ -101,7 +121,8 @@ variable "compute" {
101
121
Mapping defining homogenous groups of compute nodes. Groups are used
102
122
in Slurm partition definitions.
103
123
104
- Keys are names of groups.
124
+ Keys are names of groups, and cannot be 'compute', 'login', 'control', 'default'
125
+ or keys in the login or additional_nodegroups variables.
105
126
Values are a mapping as follows:
106
127
107
128
Required:
@@ -139,6 +160,12 @@ variable "compute" {
139
160
EOF
140
161
141
162
type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
163
+ validation {
164
+ condition = length (setintersection (keys (var. compute ), [" login" , " compute" , " control" , " default" ])) == 0
165
+ error_message = <<- EOF
166
+ Compute nodegroup names cannot be 'compute', 'default', 'login' or 'control'. Invalid var.compute key(s): ${ join (" , " , setintersection (keys (var. compute ), [" login" , " compute" , " control" , " default" ]))} .
167
+ EOF
168
+ }
142
169
}
143
170
144
171
# tflint-ignore: terraform_typed_variables
@@ -149,7 +176,8 @@ variable "additional_nodegroups" {
149
176
These nodes are not in the compute or login inventory groups so they
150
177
will not run slurmd.
151
178
152
- Keys are names of groups.
179
+ Keys are names of groups and cannot be 'login', 'compute, 'control', or
180
+ keys in the login or additional_nodegroups variables.
153
181
Values are a mapping as for the "login" variable, with the addition of
154
182
the optional entry:
155
183
@@ -162,6 +190,13 @@ variable "additional_nodegroups" {
162
190
- $cluster_name + '_' + $group_name
163
191
- 'additional'
164
192
EOF
193
+ type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
194
+ validation {
195
+ condition = length (setintersection (keys (var. additional_nodegroups ), [" login" , " compute" , " control" ])) == 0
196
+ error_message = <<- EOF
197
+ Additional nodegroup names cannot be 'compute', 'login' or 'control'. Invalid var.additional_nodegroups key(s): ${ join (" , " , setintersection (keys (var. additional_nodegroups ), [" login" , " compute" , " control" ]))} .
198
+ EOF
199
+ }
165
200
}
166
201
167
202
variable "environment_root" {
0 commit comments