-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
344 lines (319 loc) · 9.99 KB
/
variables.tf
File metadata and controls
344 lines (319 loc) · 9.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
variable "projects" {
description = <<-EOT
Map of projects. Keys are project name. Values are mappings with keys/values:
description: Optional string
compute_quota: mapping
network_quota: mapping
blockstorage_quota: mapping
For keys/values for quotas see type declarations
EOT
type = map(
object({
description = optional(string)
compute_quota = optional(
object({
key_pairs = optional(number)
ram = optional(number)
cores = optional(number)
instances = optional(number)
server_groups = optional(number)
server_group_members = optional(number)
})
)
blockstorage_quota = optional(
object({
volumes = optional(number)
snapshots = optional(number)
gigabytes = optional(number)
per_volume_gigabytes = optional(number)
backups = optional(number)
backup_gigabytes = optional(number)
groups = optional(number)
volume_type_quota = optional(map(any)) # TODO: improve!
})
)
network_quota = optional(
object({
floatingip = optional(number)
network = optional(number)
port = optional(number)
rbac_policy = optional(number)
router = optional(number)
security_group = optional(number)
security_group_rule = optional(number)
subnet = optional(number)
subnetpool = optional(number)
})
)
})
)
default = {}
}
variable "groups" {
description = "Map of groups. Keys are group names, values are group descriptions"
type = map(string)
default = {}
}
variable "users" {
description = <<-EOT
Map of users. Keys are user names. Values are mappings with keys/values:
description: Optional string
email: Optional string
groups: Optional list of group name strings, must be keys from var.groups
password: Optional string **WARNING** this will be saved in state
default_project: Optional string with name of default project, must be key in var.projects
If password is provided, this must be changed on first use.
EOT
type = map(
object({
description = optional(string)
email = optional(string)
groups = optional(list(string))
password = optional(string)
default_project = optional(string)
})
)
default = {}
}
variable "role_assignments" {
description = <<-EOT
List of role assignments. Elements are maps with keys/values:
role: string name of pre-existing role
group: string group name, a key from var.groups
project: string project name, a key from var.projects
Note an error will occur if elements are not unique.
EOT
type = list(
object({
role = string
group = string
project = string
})
)
default = []
}
variable "network_rbac" {
description = <<-EOT
List of network RBAC configurations. Elements are maps with keys/values:
network: string name of pre-existing network
projects: list of project name strings, must be keys from var.projects
access: string access type, "access_as_external" or "access_as_shared"
EOT
type = list(
object({
network = string
projects = list(string)
access = string
})
)
validation {
condition = alltrue([for v in var.network_rbac : contains(["access_as_external", "access_as_shared"], v.access)])
error_message = "Value for access must be access_as_external or access_as_shared"
}
default = []
}
variable "networks" {
type = map(
object({
region = optional(string)
shared = optional(bool, false)
external = optional(bool, false)
admin_state_up = optional(bool)
tentant_id = optional(string)
mtu = optional(number)
port_security_enabled = optional(bool, true)
tags = optional(list(string), [])
segments = optional(
list(object({
physical_network = optional(string)
network_type = optional(string)
segmentation_id = optional(number)
})), []
)
})
)
default = {}
}
variable "subnets" {
# TODO: make child of network, and automatically set network_id. See e.g. stuff in projects.tf
# TODO: make cidr or subnetpool_id required via validation
type = map(
object({
network_id = string
region = optional(string)
cidr = optional(string)
ip_version = optional(number, 4)
tentant_id = optional(string)
gateway_ip = optional(string)
enable_dhcp = optional(bool, true)
dns_nameservers = optional(list(string), [])
dns_publish_fixed_ip = optional(bool, false)
service_types = optional(list(string), [])
subnetpool_id = optional(string)
no_gateway = optional(bool)
tags = optional(list(string), [])
allocation_pool = optional(
list(object({
start = string
end = string
})), []
)
})
)
default = {}
}
variable "routers" {
type = map(
object({
region = optional(string)
external_network_id = optional(string)
admin_state_up = optional(bool)
tentant_id = optional(string)
tags = optional(list(string), [])
external_fixed_ip = optional(
list(object({
subnet_id = optional(string)
ip_address = optional(string)
})), []
)
})
)
default = {}
}
variable "router_interfaces"{
type = map(
object({
router_id = optional(string)
region = optional(string)
subnet_id = optional(string)
port_id = optional(string)
force_destroy = optional(bool, false)
})
)
default = {}
}
variable "flavors" {
description = <<-EOT
Mapping of flavor definitions. Key is flavor name, and must be quoted
if it contains ".". Values are mappings with with keys/values:
ram: Required integer
vcpus: Required integer
disk: Required integer
ephemeral: Optional integer
swap: Optional integer
rx_tx_factor: Optional
is_public: Optional bool, default true. If "projects" is non-empty
this is ignored and set false
flavor_id: Optional string
extra_specs: Optional mapping
projects: Optional list of project names to which flavor should be
mapped (i.e. flavor only visible/usable from these projects). Project
names must be keys from var.projects.
EOT
type = map(
object({
ram = number
vcpus = number
disk = number
ephemeral = optional(number)
swap = optional(number)
rx_tx_factor = optional(number)
is_public = optional(bool, true)
flavor_id = optional(string)
extra_specs = optional(map(string))
projects = optional(list(string), [])
})
)
default = {}
}
variable "images"{
description = <<-EOT
Mapping of image definitions. Key is image name.
container_format: Required string
disk_format: Required string
image_cache_path: Optional string
image_source_url: Optional string
image_id: Optional string
min_disk_gb: Optional number, default 0.
min_ram_mb: Optional number, default 0.
protected: Optional bool, default false
hidden: Optional bool, default false
web_download: Optional bool, default false
properties: Optional list of string
visibility: Optional string
EOT
type = map(
object({
container_format = string
disk_format = string
image_cache_path = optional(string)
image_source_url = optional(string)
image_id = optional(string)
min_disk_gb = optional(number)
min_ram_mb = optional(number)
protected = optional(bool, false)
hidden = optional(bool, false)
web_download = optional(bool, false)
properties = optional(map(string))
visibility = optional(string)
})
)
default = {}
}
variable "shares"{
type = map(
object({
share_proto = string
size = number
region = optional(string)
description = optional(string)
share_type = optional(string)
snapshot_id = optional(string)
is_public = optional(bool, false)
metadata = optional(string)
share_network_id = optional(string)
availability_zone = optional(string)
})
)
default = {}
}
# TODO: more outputs?
output "projects" {
#value = {for k, v in openstack_identity_project_v3.project: k => v.id}
value = openstack_identity_project_v3.project
}
output "groups" {
#value = {for k, v in openstack_identity_group_v3.group: k => v.id}
value = openstack_identity_group_v3.group
}
output "role_assignments" {
value = openstack_identity_role_assignment_v3.role_assign
}
# output "debug" {
# value = {for v in flatten([for rbac in var.network_rbac: [for project in rbac.projects: {rbac=rbac, project=project}]]): "${v.rbac.network}:${v.project}" => v}
# }
output "subnet" {
value = {
for k, v in openstack_networking_subnet_v2.subnets :
k => {
id = v.id
gateway_ip = v.gateway_ip
}
}
}
output "network" {
value = {
for k, v in openstack_networking_network_v2.networks :
k => {
id = v.id
}
}
}
output "router" {
value = {
for k, v in openstack_networking_router_v2.routers :
k => {
id = v.id
}
}
}