From aa1f48cd59b0f249cfb143761da3045a53610e53 Mon Sep 17 00:00:00 2001
From: Chris King <kingtc@uab.edu>
Date: Thu, 8 Jul 2021 15:21:31 -0500
Subject: [PATCH] Removed unused disks; add OSD disks

* Remove erroneous disks from instance configuration
* Utilize dynamic blocks to add adjustable amounts of disks to OSD nodes
---
 compute.tf   | 35 ++++++++++-------------------------
 variables.tf |  6 ++++++
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/compute.tf b/compute.tf
index 2d03eae..51b4d4f 100644
--- a/compute.tf
+++ b/compute.tf
@@ -45,15 +45,6 @@ resource "openstack_compute_instance_v2" "mgr" {
     delete_on_termination = true
   }
 
-  block_device {
-    # and the volume to copy to
-    source_type           = "blank"
-    destination_type      = "volume"
-    volume_size           = 10
-    boot_index            = 1
-    delete_on_termination = true
-  }
-
   network {
     uuid = openstack_networking_network_v2.public_network.id
   }
@@ -88,13 +79,16 @@ resource "openstack_compute_instance_v2" "osd" {
     delete_on_termination = true
   }
 
-  block_device {
-    # and the volume to copy to
-    source_type           = "blank"
-    destination_type      = "volume"
-    volume_size           = 10
-    boot_index            = 1
-    delete_on_termination = true
+  dynamic "block_device" { # JBOD disks
+    for_each = var.osd_disk_sizes
+
+    content {
+      source_type           = "blank"
+      destination_type      = "volume"
+      volume_size           = block_device.value
+      boot_index            = -1
+      delete_on_termination = true
+    }
   }
 
   network {
@@ -130,15 +124,6 @@ resource "openstack_compute_instance_v2" "mds" {
     delete_on_termination = true
   }
 
-  block_device {
-    # and the volume to copy to
-    source_type           = "blank"
-    destination_type      = "volume"
-    volume_size           = 10
-    boot_index            = 1
-    delete_on_termination = true
-  }
-
   network {
     uuid = openstack_networking_network_v2.public_network.id
   }
diff --git a/variables.tf b/variables.tf
index 9cb38e9..c245ccc 100644
--- a/variables.tf
+++ b/variables.tf
@@ -61,3 +61,9 @@ variable "sles_ses_reg" {
   type        = string
   description = "code to register for the storage package in SUSE"
 }
+
+variable "osd_disk_sizes" {
+  type        = list(number)
+  default     = [8, 8]
+  description = "Amount and size of disks (in GB) to add to each OSD node. By default, add two 8GB nodes"
+}
-- 
GitLab