File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
environments/skeleton/{{cookiecutter.environment}}/tofu Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11locals {
2- control_volumes = concat ([openstack_blockstorage_volume_v3 . state ], var. home_volume_size > 0 ? [openstack_blockstorage_volume_v3 . home ][0 ] : [])
2+ control_volumes = concat (
3+ [openstack_blockstorage_volume_v3 . state ],
4+ # convert map to list:
5+ [for v in data . openstack_blockstorage_volume_v3 . home : v ]
6+ )
37 nodename = templatestring (
48 var. cluster_nodename_template ,
59 {
Original file line number Diff line number Diff line change @@ -119,6 +119,11 @@ variable "state_volume_size" {
119119 default = 150 # GB
120120}
121121
122+ /* variable "state_volume_mode" {
123+ type = string
124+ description = "Whether to "
125+ }
126+ */
122127variable "state_volume_type" {
123128 type = string
124129 description = " Type of state volume, if not default type"
@@ -127,8 +132,11 @@ variable "state_volume_type" {
127132
128133variable "home_volume_size" {
129134 type = number
130- description = " Size of state volume on control node, in GB"
131- default = 100 # GB, 0 means no home volume
135+ description = <<- EOT
136+ Size of state volume on control node, in GB. If zero, a volume with the
137+ name $cluster_name-home must already exist unless home_volume_enabled = false
138+ EOT
139+ default = 100
132140}
133141
134142variable "home_volume_type" {
@@ -137,6 +145,12 @@ variable "home_volume_type" {
137145 description = " Type of home volume, if not default type"
138146}
139147
148+ variable "home_volume_enabled" {
149+ type = bool
150+ default = true
151+ description = " Whether to use a home volume"
152+ }
153+
140154variable "vnic_types" {
141155 type = map (string )
142156 description = <<- EOT
Original file line number Diff line number Diff line change @@ -7,10 +7,39 @@ resource "openstack_blockstorage_volume_v3" "state" {
77
88resource "openstack_blockstorage_volume_v3" "home" {
99
10+ # NB: Changes CANNOT be made to this resource's "address"
11+ # i.e. (label or for_each key)
12+ # else existing clusters may get home volumes deleted and recreated!
13+
1014 count = var. home_volume_size > 0 ? 1 : 0
1115
1216 name = " ${ var . cluster_name } -home" # last word used to label filesystem
1317 description = " Home for control node"
1418 size = var. home_volume_size
1519 volume_type = var. home_volume_type
1620}
21+
22+ data "openstack_blockstorage_volume_v3" "home" {
23+
24+ /* May or may not have a volume, depending on home_volume_enabled, so this
25+ has to use for_each.
26+
27+ For the case where we use the above provisioned volume resource, we need
28+ to create a depenency on it to avoid a race.
29+
30+ The logic is:
31+ - If not home_volume_enabled, there is no volume
32+ - Else if home_volume_size > 0 - use the provisioned volume resource
33+ - Else find an existing volume with the specified name
34+ */
35+
36+ for_each = toset (
37+ (var. home_volume_enabled ) ? (
38+ (var. home_volume_size > 0 ) ?
39+ [for v in openstack_blockstorage_volume_v3 . home : v . name ] :
40+ [" ${ var . cluster_name } -home" ]
41+ ) : []
42+ )
43+
44+ name = each. key
45+ }
You can’t perform that action at this time.
0 commit comments