-
Notifications
You must be signed in to change notification settings - Fork 0
/
hadoop-client.tf
88 lines (73 loc) · 2.4 KB
/
hadoop-client.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
resource "time_sleep" "wait_5_seconds" {
depends_on = [null_resource.nullremote3]
create_duration = "5s"
}
resource "aws_instance" "web4" {
ami = var.ami_id
instance_type = var.machine_type
key_name = var.keyName
security_groups = [aws_security_group.minorprojectsecurity.id]
subnet_id = var.subnetID
tags = {
Name = "client-1"
}
}
resource "null_resource" "nullremote9" {
depends_on = [time_sleep.wait_5_seconds]
connection {
type = "ssh"
user = "ec2-user"
private_key = file(var.keyLocation)
host = aws_instance.web4.public_ip
}
provisioner "remote-exec" {
inline = [
"sudo yum install git -y",
"sudo rpm -ivh --force https://repo.huaweicloud.com/java/jdk/8u171-b11/jdk-8u171-linux-x64.rpm",
"sudo rpm -ivh https://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/hadoop-1.2.1-1.x86_64.rpm --force",
"cd",
"sudo rm -rf core-site.xml",
"cd",
"sudo git clone https://github.com/yadvi12/Hadoop-configuration-files.git /hdfs",
"cd /hdfs",
"sudo sed -i 's/0.0.0.0/${aws_instance.web.public_ip}/' core-site.xml",
"sudo mv core-site.xml /etc/hadoop",
"sudo hadoop fs -touchz a.txt"
]
}
}
# 2nd client
resource "aws_instance" "web5" {
ami = var.ami_id
instance_type = var.machine_type
key_name = var.keyName
security_groups = [aws_security_group.minorprojectsecurity.id]
subnet_id = var.subnetID
tags = {
Name = "client-2"
}
}
resource "null_resource" "nullremote10" {
depends_on = [time_sleep.wait_5_seconds]
connection {
type = "ssh"
user = "ec2-user"
private_key = file(var.keyLocation)
host = aws_instance.web5.public_ip
}
provisioner "remote-exec" {
inline = [
"sudo yum install git -y",
"sudo rpm -ivh --force https://repo.huaweicloud.com/java/jdk/8u171-b11/jdk-8u171-linux-x64.rpm",
"sudo rpm -ivh https://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/hadoop-1.2.1-1.x86_64.rpm --force",
"cd",
"sudo rm -rf core-site.xml",
"cd",
"sudo git clone https://github.com/yadvi12/Hadoop-configuration-files.git /hdfs",
"cd /hdfs",
"sudo sed -i 's/0.0.0.0/${aws_instance.web.public_ip}/' core-site.xml",
"sudo mv core-site.xml /etc/hadoop",
"sudo hadoop fs -touchz b.txt"
]
}
}