File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed
environments/skeleton/{{cookiecutter.environment}}/terraform Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ module "compute" {
18
18
vnic_profile = lookup (each. value , " vnic_profile" , var. vnic_profile )
19
19
volume_backed_instances = lookup (each. value , " volume_backed_instances" , var. volume_backed_instances )
20
20
root_volume_size = lookup (each. value , " root_volume_size" , var. root_volume_size )
21
+ extra_volumes = lookup (each. value , " extra_volumes" , {})
21
22
22
23
key_pair = var. key_pair
23
24
environment_root = var. environment_root
Original file line number Diff line number Diff line change
1
+ locals {
2
+ all_compute_volumes = {for v in setproduct (var. nodes , keys (var. extra_volumes )): " ${ v [0 ]} -${ v [1 ]} " => {" node" = v[0 ], " volume" = v[1 ]}}
3
+ # e.g. with
4
+ # var.nodes = ["compute-0", "compute-1"]
5
+ # var.extra_volumes = {
6
+ # "vol-a" = {size = 10},
7
+ # "vol-b" = {size = 20}
8
+ # }
9
+ # this is a mapping with
10
+ # keys "compute-0-vol-a", "compute-0-vol-b" ...
11
+ # values which are a mapping e.g. {"node"="compute-0", "volume"="vol-a"}
12
+ }
13
+
14
+ resource "openstack_blockstorage_volume_v3" "compute" {
15
+
16
+ for_each = local. all_compute_volumes
17
+
18
+ name = " ${ var . cluster_name } -${ each . key } "
19
+ description = " Compute node ${ each . value . node } volume ${ each . value . volume } "
20
+ size = var. extra_volumes [each . value . volume ]. size
21
+ }
22
+
23
+ resource "openstack_compute_volume_attach_v2" "compute" {
24
+
25
+ for_each = local. all_compute_volumes
26
+
27
+ instance_id = openstack_compute_instance_v2. compute [" ${ each . value . node } " ]. id
28
+ volume_id = openstack_blockstorage_volume_v3. compute [" ${ each . key } " ]. id
29
+ }
30
+
1
31
resource "openstack_networking_port_v2" "compute" {
2
32
3
33
for_each = toset (var. nodes )
Original file line number Diff line number Diff line change @@ -64,6 +64,18 @@ variable "root_volume_size" {
64
64
default = 40
65
65
}
66
66
67
+ variable "extra_volumes" {
68
+ description = <<- EOF
69
+ Mapping defining additional volumes to create and attach.
70
+ Keys are unique volume name.
71
+ Values are a mapping with:
72
+ size: Size of volume in GB
73
+ **NB**: The order in /dev is not guaranteed to match the mapping
74
+ EOF
75
+ type = any
76
+ default = {}
77
+ }
78
+
67
79
variable "security_group_ids" {
68
80
type = list
69
81
}
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ variable "compute" {
54
54
vnic_profile: Overrides variable vnic_profile
55
55
volume_backed_instances: Overrides variable volume_backed_instances
56
56
root_volume_size: Overrides variable root_volume_size
57
+ extra_volumes: Mapping defining additional volumes to create and attach
58
+ Keys are unique volume name.
59
+ Values are a mapping with:
60
+ size: Size of volume in GB
61
+ **NB**: The order in /dev is not guaranteed to match the mapping
57
62
EOF
58
63
}
59
64
You can’t perform that action at this time.
0 commit comments