|
| 1 | +// Block Volume Creation for Bastion |
| 2 | + |
| 3 | +# Log Volume for /var/log/cloudera |
| 4 | +resource "oci_core_volume" "BastionLogVolume" { |
| 5 | + count = "1" |
| 6 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 7 | + compartment_id = "${var.compartment_ocid}" |
| 8 | + display_name = "Bastion ${format("%01d", count.index+1)} Log Data" |
| 9 | + size_in_gbs = "${var.log_volume_size_in_gbs}" |
| 10 | +} |
| 11 | + |
| 12 | +resource "oci_core_volume_attachment" "BastionLogAttachment" { |
| 13 | + count = "1" |
| 14 | + attachment_type = "iscsi" |
| 15 | + compartment_id = "${var.compartment_ocid}" |
| 16 | + instance_id = "${oci_core_instance.Bastion.id}" |
| 17 | + volume_id = "${oci_core_volume.BastionLogVolume.id}" |
| 18 | + device = "/dev/oracleoci/oraclevdb" |
| 19 | +} |
| 20 | + |
| 21 | +# Data Volume for /opt/cloudera |
| 22 | +resource "oci_core_volume" "BastionClouderaVolume" { |
| 23 | + count = "1" |
| 24 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 25 | + compartment_id = "${var.compartment_ocid}" |
| 26 | + display_name = "Bastion ${format("%01d", count.index+1)} Cloudera Data" |
| 27 | + size_in_gbs = "${var.cloudera_volume_size_in_gbs}" |
| 28 | +} |
| 29 | + |
| 30 | +resource "oci_core_volume_attachment" "BastionClouderaAttachment" { |
| 31 | + count = "1" |
| 32 | + attachment_type = "iscsi" |
| 33 | + compartment_id = "${var.compartment_ocid}" |
| 34 | + instance_id = "${oci_core_instance.Bastion.id}" |
| 35 | + volume_id = "${oci_core_volume.BastionClouderaVolume.id}" |
| 36 | + device = "/dev/oracleoci/oraclevdc" |
| 37 | +} |
| 38 | + |
| 39 | +// Block Volume Creation for Utility |
| 40 | + |
| 41 | +# Log Volume for /var/log/cloudera |
| 42 | +resource "oci_core_volume" "UtilLogVolume" { |
| 43 | + count = "1" |
| 44 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 45 | + compartment_id = "${var.compartment_ocid}" |
| 46 | + display_name = "Cloudera Manager ${format("%01d", count.index+1)} Log Data" |
| 47 | + size_in_gbs = "${var.log_volume_size_in_gbs}" |
| 48 | +} |
| 49 | + |
| 50 | +resource "oci_core_volume_attachment" "UtilLogAttachment" { |
| 51 | + count = "1" |
| 52 | + attachment_type = "iscsi" |
| 53 | + compartment_id = "${var.compartment_ocid}" |
| 54 | + instance_id = "${oci_core_instance.Utility.id}" |
| 55 | + volume_id = "${oci_core_volume.UtilLogVolume.id}" |
| 56 | + device = "/dev/oracleoci/oraclevdb" |
| 57 | +} |
| 58 | + |
| 59 | +# Data Volume for /opt/cloudera |
| 60 | +resource "oci_core_volume" "UtilClouderaVolume" { |
| 61 | + count = "1" |
| 62 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 63 | + compartment_id = "${var.compartment_ocid}" |
| 64 | + display_name = "Cloudera Manager ${format("%01d", count.index+1)} Data" |
| 65 | + size_in_gbs = "${var.cloudera_volume_size_in_gbs}" |
| 66 | +} |
| 67 | + |
| 68 | +resource "oci_core_volume_attachment" "UtilClouderaAttachment" { |
| 69 | + count = "1" |
| 70 | + attachment_type = "iscsi" |
| 71 | + compartment_id = "${var.compartment_ocid}" |
| 72 | + instance_id = "${oci_core_instance.Utility.id}" |
| 73 | + volume_id = "${oci_core_volume.UtilClouderaVolume.id}" |
| 74 | + device = "/dev/oracleoci/oraclevdc" |
| 75 | +} |
| 76 | + |
| 77 | + |
| 78 | +// Block Volume Creation for Master |
| 79 | + |
| 80 | +# Log Volume for /var/log/cloudera |
| 81 | +resource "oci_core_volume" "MasterLogVolume" { |
| 82 | + count = "${var.master_node_count}" |
| 83 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 84 | + compartment_id = "${var.compartment_ocid}" |
| 85 | + display_name = "Cloudera Master ${format("%01d", count.index+1)} Log Data" |
| 86 | + size_in_gbs = "${var.log_volume_size_in_gbs}" |
| 87 | +} |
| 88 | + |
| 89 | +resource "oci_core_volume_attachment" "MasterLogAttachment" { |
| 90 | + count = "${var.master_node_count}" |
| 91 | + attachment_type = "iscsi" |
| 92 | + compartment_id = "${var.compartment_ocid}" |
| 93 | + instance_id = "${oci_core_instance.Master.*.id[count.index]}" |
| 94 | + volume_id = "${oci_core_volume.MasterLogVolume.*.id[count.index]}" |
| 95 | + device = "/dev/oracleoci/oraclevdb" |
| 96 | +} |
| 97 | + |
| 98 | +# Data Volume for /opt/cloudera |
| 99 | +resource "oci_core_volume" "MasterClouderaVolume" { |
| 100 | + count = "${var.master_node_count}" |
| 101 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 102 | + compartment_id = "${var.compartment_ocid}" |
| 103 | + display_name = "Cloudera Master ${format("%01d", count.index+1)} Cloudera Data" |
| 104 | + size_in_gbs = "${var.cloudera_volume_size_in_gbs}" |
| 105 | +} |
| 106 | + |
| 107 | +resource "oci_core_volume_attachment" "MasterClouderaAttachment" { |
| 108 | + count = "1" |
| 109 | + attachment_type = "iscsi" |
| 110 | + compartment_id = "${var.compartment_ocid}" |
| 111 | + instance_id = "${oci_core_instance.Master.*.id[count.index]}" |
| 112 | + volume_id = "${oci_core_volume.MasterClouderaVolume.*.id[count.index]}" |
| 113 | + device = "/dev/oracleoci/oraclevdc" |
| 114 | +} |
| 115 | + |
| 116 | +# Data Volume for /data (Name & SecondaryName) |
| 117 | +resource "oci_core_volume" "MasterNNVolume" { |
| 118 | + count = "${var.master_node_count}" |
| 119 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 120 | + compartment_id = "${var.compartment_ocid}" |
| 121 | + display_name = "Cloudera Master ${format("%01d", count.index+1)} Journal Data" |
| 122 | + size_in_gbs = "${var.nn_volume_size_in_gbs}" |
| 123 | +} |
| 124 | + |
| 125 | +resource "oci_core_volume_attachment" "MasterNNAttachment" { |
| 126 | + count = "${var.master_node_count}" |
| 127 | + attachment_type = "iscsi" |
| 128 | + compartment_id = "${var.compartment_ocid}" |
| 129 | + instance_id = "${oci_core_instance.Master.*.id[count.index]}" |
| 130 | + volume_id = "${oci_core_volume.MasterNNVolume.*.id[count.index]}" |
| 131 | + device = "/dev/oracleoci/oraclevdd" |
| 132 | +} |
| 133 | + |
| 134 | +// Block Volume Creation for Worker |
| 135 | + |
| 136 | +# Log Volume for /var/log/cloudera |
| 137 | +resource "oci_core_volume" "WorkerLogVolume" { |
| 138 | + count = "${var.worker_node_count}" |
| 139 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 140 | + compartment_id = "${var.compartment_ocid}" |
| 141 | + display_name = "Cloudera Worker ${format("%01d", count.index+1)} Log Data" |
| 142 | + size_in_gbs = "${var.log_volume_size_in_gbs}" |
| 143 | +} |
| 144 | + |
| 145 | +resource "oci_core_volume_attachment" "WorkerLogAttachment" { |
| 146 | + count = "${var.worker_node_count}" |
| 147 | + attachment_type = "iscsi" |
| 148 | + compartment_id = "${var.compartment_ocid}" |
| 149 | + instance_id = "${oci_core_instance.Worker.*.id[count.index]}" |
| 150 | + volume_id = "${oci_core_volume.WorkerLogVolume.*.id[count.index]}" |
| 151 | + device = "/dev/oracleoci/oraclevdb" |
| 152 | +} |
| 153 | + |
| 154 | +# Data Volume for /opt/cloudera |
| 155 | +resource "oci_core_volume" "WorkerClouderaVolume" { |
| 156 | + count = "${var.worker_node_count}" |
| 157 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 158 | + compartment_id = "${var.compartment_ocid}" |
| 159 | + display_name = "Cloudera Worker ${format("%01d", count.index+1)} Cloudera Data" |
| 160 | + size_in_gbs = "${var.cloudera_volume_size_in_gbs}" |
| 161 | +} |
| 162 | + |
| 163 | +resource "oci_core_volume_attachment" "WorkerClouderaAttachment" { |
| 164 | + count = "${var.worker_node_count}" |
| 165 | + attachment_type = "iscsi" |
| 166 | + compartment_id = "${var.compartment_ocid}" |
| 167 | + instance_id = "${oci_core_instance.Worker.*.id[count.index]}" |
| 168 | + volume_id = "${oci_core_volume.WorkerClouderaVolume.*.id[count.index]}" |
| 169 | + device = "/dev/oracleoci/oraclevdc" |
| 170 | +} |
| 171 | + |
| 172 | +# Data Volumes for HDFS |
| 173 | +resource "oci_core_volume" "WorkerDataVolume" { |
| 174 | + count = "${var.worker_node_count * (ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs)/var.worker_node_count))}" |
| 175 | + availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.availability_domain - 1],"name")}" |
| 176 | + compartment_id = "${var.compartment_ocid}" |
| 177 | + display_name = "Cloudera Worker ${format("%01d", (count.index / (ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs)/var.worker_node_count)))+1)} HDFS Data ${format("%01d", (count.index%((ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs))/var.worker_node_count)))+1)}" |
| 178 | + size_in_gbs = "${var.data_blocksize_in_gbs}" |
| 179 | +} |
| 180 | + |
| 181 | +resource "oci_core_volume_attachment" "WorkerDataAttachment" { |
| 182 | + count = "${var.worker_node_count * (ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs)/var.worker_node_count))}" |
| 183 | + attachment_type = "iscsi" |
| 184 | + compartment_id = "${var.compartment_ocid}" |
| 185 | + instance_id = "${oci_core_instance.Worker.*.id[count.index / (ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs)/var.worker_node_count))]}" |
| 186 | + volume_id = "${oci_core_volume.WorkerDataVolume.*.id[count.index]}" |
| 187 | + device = "${var.data_volume_attachment_device[count.index%(ceil(((var.hdfs_usable_in_gbs*3)/var.data_blocksize_in_gbs)/var.worker_node_count))]}" |
| 188 | +} |
| 189 | + |
0 commit comments