-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompute.tf
194 lines (168 loc) · 6.73 KB
/
compute.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
resource "oci_core_instance" "ComputeNode" {
count = "${var.ComputeNodeCount}"
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${var.ComputeNodeHostnamePrefix}${format("%01d", count.index+1)}"
hostname_label = "${var.ComputeNodeHostnamePrefix}${format("%01d", count.index+1)}"
shape = "${var.ComputeNodeShape}"
subnet_id = "${oci_core_subnet.private.*.id[var.AD - 1]}"
source_details {
source_type = "image"
source_id = "${var.InstanceImageOCID[var.region]}"
}
launch_options {
network_type = (length(regexall("VM.Standard.E", var.ComputeNodeShape)) > 0 ? "PARAVIRTUALIZED" : "VFIO")
}
metadata = {
ssh_authorized_keys = "${var.ssh_public_key}"
#user_data = "${base64encode(data.template_file.boot_script.rendered)}"
user_data = "${base64encode(join("\n", list(
"#!/usr/bin/env bash",
"set -x",
"version=\"${var.ibm_ss_version}\"",
"downloadUrl=\"${var.software_download_url}\"",
"sshPrivateKey=\"${var.ssh_private_key}\"",
"sshPublicKey=\"${var.ssh_public_key}\"",
"clientNodeCount=\"${var.ComputeNodeCount}\"",
"clientNodeHostnamePrefix=\"${var.ComputeNodeHostnamePrefix}\"",
"blockSize=\"${var.BlockSize}\"",
"dataReplica=\"${var.DataReplica}\"",
"metadataReplica=\"${var.metadataReplica}\"",
"gpfsMountPoint=\"${var.GpfsMountPoint}\"",
"fileSystemName=\"${var.fileSystemName}\"",
"sharedDataDiskCount=\"${var.SharedData["Count"]}\"",
"installerNode=\"${var.ComputeNodeHostnamePrefix}${var.installer_node}\"",
"privateSubnetsFQDN=\"${oci_core_subnet.private.*.dns_label[var.AD - 1]}.${oci_core_virtual_network.ibmss_vcnv3.dns_label}.oraclevcn.com\"",
file("${var.scripts_directory}/boot.sh")
)))}"
}
timeouts {
create = "60m"
}
}
/* bastion instances */
resource "oci_core_instance" "bastion" {
count = "${var.BastionNodeCount}"
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "bastion ${format("%01d", count.index+1)}"
shape = "${var.BastionNodeShape}"
hostname_label = "bastion-${format("%01d", count.index+1)}"
create_vnic_details {
subnet_id = "${oci_core_subnet.public.*.id[var.AD - 1]}"
skip_source_dest_check = true
}
metadata = {
ssh_authorized_keys = "${var.ssh_public_key}"
}
source_details {
source_type = "image"
source_id = "${var.InstanceImageOCID[var.region]}"
}
}
/* Remote exec to deploy gpfs software/rpms on client nodes */
resource "null_resource" "deploy_gpfs_on_client_nodes" {
depends_on = [
oci_core_instance.ComputeNode,
null_resource.notify_compute_nodes_oci_cli_multi_attach_complete,
]
count = var.ComputeNodeCount
triggers = {
instance_ids = "oci_core_instance.client_node.*.id"
}
provisioner "file" {
source = "${var.scripts_directory}/nodes-cloud-init-complete-status-check.sh"
destination = "/tmp/nodes-cloud-init-complete-status-check.sh"
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[0].public_ip
bastion_port = "22"
bastion_user = var.ssh_user
bastion_private_key = var.ssh_private_key
}
}
provisioner "file" {
source = "${var.scripts_directory}/deploy_spectrum_scale.sh"
destination = "/tmp/deploy_spectrum_scale.sh"
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[0].public_ip
bastion_port = "22"
bastion_user = var.ssh_user
bastion_private_key = var.ssh_private_key
}
}
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[0].public_ip
bastion_port = "22"
bastion_user = var.ssh_user
bastion_private_key = var.ssh_private_key
}
inline = [
"set -x",
"echo about to run /tmp/nodes-cloud-init-complete-status-check.sh",
"sudo -s bash -c 'set -x && chmod 777 /tmp/*.sh'",
"sudo -s bash -c 'set -x && /tmp/nodes-cloud-init-complete-status-check.sh'",
"sudo -s bash -c 'set -x && /tmp/deploy_spectrum_scale.sh'",
]
}
}
/* Remote exec to create gpfs cluster on installer node */
resource "null_resource" "create_gpfs_cluster" {
depends_on = [
oci_core_instance.ComputeNode,
null_resource.notify_compute_nodes_oci_cli_multi_attach_complete,
null_resource.deploy_gpfs_on_client_nodes,
]
count = 1
triggers = {
instance_ids = "oci_core_instance.client_node.*.id"
}
provisioner "file" {
source = "${var.scripts_directory}/create_spectrum_scale_cluster.sh"
destination = "/tmp/create_spectrum_scale_cluster.sh"
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[0].public_ip
bastion_port = "22"
bastion_user = var.ssh_user
bastion_private_key = var.ssh_private_key
}
}
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[0].public_ip
bastion_port = "22"
bastion_user = var.ssh_user
bastion_private_key = var.ssh_private_key
}
inline = [
"set -x",
"sudo -s bash -c 'set -x && chmod 777 /tmp/*.sh'",
"sudo su -l -c 'set -x && /tmp/create_spectrum_scale_cluster.sh'",
]
}
}