This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbluedata_infra_scripts.tf
251 lines (226 loc) · 9.08 KB
/
bluedata_infra_scripts.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
resource "local_file" "ssh_controller" {
filename = "${path.module}/generated/ssh_controller.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PUB_IP "$@"
EOF
}
resource "local_file" "ssh_controller_private" {
filename = "${path.module}/generated/ssh_controller_private.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PRV_IP "$@"
EOF
}
resource "local_file" "ssh_gateway" {
filename = "${path.module}/generated/ssh_gateway.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$GATW_PUB_IP "$@"
EOF
}
resource "local_file" "ssh_ad" {
filename = "${path.module}/generated/ssh_ad.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$AD_PUB_IP "$@"
EOF
}
resource "local_file" "ssh_worker" {
count = var.worker_count
filename = "${path.module}/generated/ssh_worker_${count.index + 1}.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$${WRKR_PUB_IPS[${count.index}]} "$@"
EOF
}
resource "local_file" "ssh_worker_gpu" {
count = var.gpu_worker_count
filename = "${path.module}/generated/ssh_worker_gpu_${count.index}.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$${WRKR_GPU_PUB_IPS[${count.index}]} "$@"
EOF
}
resource "local_file" "ssh_mapr_cluster_1_host" {
count = var.mapr_cluster_1_count
filename = "${path.module}/generated/ssh_mapr_cluster_1_host_${count.index}.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$${MAPR_CLUSTER1_HOSTS_PUB_IPS[${count.index}]} "$@"
EOF
}
resource "local_file" "ssh_mapr_cluster_2_host" {
count = var.mapr_cluster_2_count
filename = "${path.module}/generated/ssh_mapr_cluster_2_host_${count.index}.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$${MAPR_CLUSTER2_HOSTS_PUB_IPS[${count.index}]} "$@"
EOF
}
resource "local_file" "ssh_workers" {
count = var.worker_count
filename = "${path.module}/generated/ssh_worker_all.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
if [[ $# -lt 1 ]]
then
echo "You must provide at least one command, e.g."
echo "./generated/ssh_worker_all.sh CMD1 CMD2 CMDn"
exit 1
fi
for HOST in $${WRKR_PUB_IPS[@]};
do
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$HOST "$@"
done
EOF
}
resource "local_file" "ssh_all" {
count = var.worker_count
filename = "${path.module}/generated/ssh_all.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
if [[ $# -lt 1 ]]
then
echo "You must provide at least one command, e.g."
echo "./generated/ssh_worker_all.sh CMD1 CMD2 CMDn"
exit 1
fi
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PUB_IP "$@"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$GATW_PUB_IP "$@"
for HOST in $${WRKR_PUB_IPS[@]};
do
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$HOST "$@"
done
EOF
}
resource "local_file" "mcs_credentials" {
filename = "${path.module}/generated/mcs_credentials.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
echo
echo ==== MCS Credentials ====
echo
echo IP Addr: $CTRL_PUB_IP
echo Username: admin
echo Password: $(ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PUB_IP "cat /opt/bluedata/mapr/conf/mapr-admin-pass")
echo
EOF
}
resource "local_file" "fix_restart_auth_proxy" {
filename = "${path.module}/generated/fix_restart_auth_proxy.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PUB_IP 'docker restart $(docker ps | grep "epic/authproxy" | cut -d " " -f1); docker ps'
EOF
}
resource "local_file" "fix_restart_webhdfs" {
filename = "${path.module}/generated/fix_restart_webhdfs.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" centos@$CTRL_PUB_IP 'docker restart $(docker ps | grep "epic/webhdfs" | cut -d " " -f1); docker ps'
EOF
}
resource "local_file" "platform_id" {
filename = "${path.module}/generated/platform_id.sh"
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
curl -s -k https://$CTRL_PUB_IP:8080/api/v1/license | python3 -c 'import json,sys;obj=json.load(sys.stdin);print (obj["uuid"])'
EOF
}
resource "local_file" "rdp_linux_credentials" {
filename = "${path.module}/generated/rdp_credentials.sh"
count = var.rdp_server_enabled == true && var.rdp_server_operating_system == "LINUX" ? 1 : 0
content = <<-EOF
#!/bin/bash
HIDE_WARNINGS=$${HIDE_WARNINGS:-0}
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
echo
if [[ $RDP_PUB_IP == "" && $HIDE_WARNINGS == 0 ]]; then
echo "WARNING: Unable to display RDP credentials because RDP_PUB_IP could not be retrieved - is the instance running?"
exit
fi
echo ================================= RDP Credentials =====================================
echo
if [[ "$CREATE_EIP_RDP_LINUX_SERVER" == "False" ]]; then
echo Note: The RDP IP addresses listed below change each time the RDP instance is restarted.
else
echo Note: The RDP IP addresses listed below are provided by an EIP and are static.
fi
echo
echo Host IP: "$RDP_PUB_IP"
echo Web Url: "https://$RDP_PUB_IP (Chrome is recommended)"
echo RDP URL: "rdp://full%20address=s:$RDP_PUB_IP:3389&username=s:ubuntu"
echo Username: "ubuntu"
echo Password: "${random_password.rdp_admin_password.result}"
echo
echo ========================================================================================
echo
EOF
}
resource "local_file" "rdp_over_ssh" {
filename = "${path.module}/generated/rdp_over_ssh.sh"
count = var.rdp_server_enabled == true && var.rdp_server_operating_system == "LINUX" ? 1 : 0
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
echo "Portforwarding 3389 on 127.0.0.1 to RDP Server [CTRL-C to cancel]"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$RDP_PUB_IP "$@" -L3389:localhost:3389 -N
EOF
}
resource "local_file" "rdp_post_setup" {
filename = "${path.module}/generated/rdp_post_provision_setup.sh"
count = var.rdp_server_enabled == true && var.rdp_server_operating_system == "LINUX" ? 1 : 0
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$RDP_PUB_IP "sudo fastdd"
EOF
}
resource "local_file" "ssh_rdp_linux" {
filename = "${path.module}/generated/ssh_rdp_linux_server.sh"
count = var.rdp_server_enabled == true && var.rdp_server_operating_system == "LINUX" ? 1 : 0
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
ssh -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$RDP_PUB_IP "$@"
EOF
}
resource "local_file" "sftp_rdp_linux" {
filename = "${path.module}/generated/sftp_rdp_linux_server.sh"
count = var.rdp_server_enabled == true && var.rdp_server_operating_system == "LINUX" ? 1 : 0
content = <<-EOF
#!/bin/bash
source "${path.module}/${var.downstream_repo_dir}/scripts/variables.sh"
sftp -o StrictHostKeyChecking=no -i "${var.ssh_prv_key_path}" ubuntu@$RDP_PUB_IP
EOF
}
resource "local_file" "whatismyip" {
filename = "${path.module}/generated/whatismyip.sh"
content = <<-EOF
#!/bin/bash
echo $(curl -s http://ifconfig.me/ip)/32
EOF
}
resource "local_file" "get_public_endpoints" {
filename = "${path.module}/generated/get_public_endpoints.sh"
content = <<-EOF
#!/usr/bin/env bash
source ./hcp-demo-env-aws-terraform/scripts/variables.sh
### TODO: add output
EOF
}