-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmulti-attach-storage.tf
123 lines (98 loc) · 5.33 KB
/
multi-attach-storage.tf
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
resource "null_resource" "copy_nsddevices_to_all_compute_nodes" {
depends_on = [oci_core_instance.ComputeNode]
count = var.ComputeNodeCount
provisioner "file" {
source = "../direct_attached_scripts/nsddevices"
destination = "/tmp/nsddevices"
connection {
agent = false
timeout = "30m"
host = "${element(oci_core_instance.ComputeNode.*.private_ip, count.index)}"
user = "${var.ssh_user}"
private_key = "${var.ssh_private_key}"
bastion_host = "${oci_core_instance.bastion.*.public_ip[0]}"
bastion_port = "22"
bastion_user = "${var.ssh_user}"
bastion_private_key = "${var.ssh_private_key}"
}
}
}
resource "null_resource" "install_oci_cli_preview" {
count = "1"
provisioner "local-exec" {
command = "set -x; oci os bucket list --compartment-id ${var.compartment_ocid};"
}
}
/*
resource "null_resource" "multi_attach_shared_data_bv_to_server_nodes" {
depends_on = ["oci_core_instance.ServerNode" , "oci_core_instance.ComputeNode", "oci_core_volume.SharedDataBlockVolume", "null_resource.install_oci_cli_preview" ]
count = "${var.ServerNodeCount * var.SharedData["Count"]}"
provisioner "local-exec" {
command = "oci compute volume-attachment attach --type iscsi --is-shareable true --instance-id ${oci_core_instance.ServerNode.*.id[count.index%var.ServerNodeCount]} --volume-id ${oci_core_volume.SharedDataBlockVolume.*.id[floor(count.index/var.ServerNodeCount)]} --device ${var.SharedDataVolumeAttachDeviceMapping[floor(count.index/var.ServerNodeCount)]};sleep 61s; "
}
}
*/
resource "null_resource" "multi_attach_shared_data_bv_to_compute_nodes" {
depends_on = [oci_core_instance.ComputeNode, oci_core_volume.SharedDataBlockVolume, null_resource.install_oci_cli_preview ]
count = "${var.ComputeNodeCount * var.SharedData["Count"]}"
provisioner "local-exec" {
command = "sleep 45s;oci compute volume-attachment attach --type iscsi --is-shareable true --instance-id ${oci_core_instance.ComputeNode.*.id[count.index%var.ComputeNodeCount]} --volume-id ${oci_core_volume.SharedDataBlockVolume.*.id[floor(count.index/var.ComputeNodeCount)]} --device ${var.SharedDataVolumeAttachDeviceMapping[floor(count.index/var.ComputeNodeCount)]} ; "
}
}
/*
resource "null_resource" "multi_attach_shared_metadata_bv_to_server_nodes" {
depends_on = ["oci_core_instance.ServerNode" , "oci_core_instance.ComputeNode", "oci_core_volume.SharedMetaDataBlockVolume", "null_resource.install_oci_cli_preview" ]
count = "${var.ServerNodeCount * var.SharedMetaData["Count"]}"
provisioner "local-exec" {
command = "sleep 90s; oci compute volume-attachment attach --type iscsi --is-shareable true --instance-id ${oci_core_instance.ServerNode.*.id[count.index%var.ServerNodeCount]} --volume-id ${oci_core_volume.SharedMetaDataBlockVolume.*.id[floor(count.index/var.ServerNodeCount)]} --device ${var.SharedMetaDataVolumeAttachDeviceMapping[floor(count.index/var.ServerNodeCount)]};"
}
}
resource "null_resource" "multi_attach_shared_metadata_bv_to_compute_nodes" {
depends_on = ["oci_core_instance.ServerNode" , "oci_core_instance.ComputeNode", "oci_core_volume.SharedMetaDataBlockVolume", "null_resource.install_oci_cli_preview" ]
count = "${var.ComputeNodeCount * var.SharedMetaData["Count"]}"
}
*/
/*
resource "null_resource" "notify_server_nodes_oci_cli_multi_attach_complete" {
depends_on = ["null_resource.multi_attach_shared_metadata_bv_to_compute_nodes" , "null_resource.multi_attach_shared_metadata_bv_to_server_nodes", null_resource.multi_attach_shared_data_bv_to_compute_nodes, "null_resource.multi_attach_shared_data_bv_to_server_nodes" ]
count = "${var.ServerNodeCount}"
provisioner "remote-exec" {
connection {
agent = false
timeout = "30m"
host = "${element(oci_core_instance.ServerNode.*.private_ip, count.index)}"
user = "${var.ssh_user}"
private_key = "${var.ssh_private_key}"
bastion_host = "${oci_core_instance.bastion.*.public_ip[0]}"
bastion_port = "22"
bastion_user = "${var.ssh_user}"
bastion_private_key = "${var.ssh_private_key}"
}
inline = [
"set -x",
"sudo touch /tmp/multi-attach.complete",
]
}
}
*/
resource "null_resource" "notify_compute_nodes_oci_cli_multi_attach_complete" {
depends_on = [null_resource.multi_attach_shared_data_bv_to_compute_nodes]
count = "${var.ComputeNodeCount}"
provisioner "remote-exec" {
connection {
agent = false
timeout = "30m"
host = "${element(oci_core_instance.ComputeNode.*.private_ip, count.index)}"
user = "${var.ssh_user}"
private_key = "${var.ssh_private_key}"
bastion_host = "${oci_core_instance.bastion.*.public_ip[0]}"
bastion_port = "22"
bastion_user = "${var.ssh_user}"
bastion_private_key = "${var.ssh_private_key}"
}
inline = [
"set -x",
"sudo touch /tmp/multi-attach.complete",
]
}
}