-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathexecutor.tf
71 lines (59 loc) · 1.9 KB
/
executor.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
locals {
auto_execute = var.auto_execute
leader_private_ip = aws_instance.leader.private_ip
executors = {
jmeter = {
nodes_ips = join(",",aws_instance.nodes.*.private_ip)
}
bzt = {
nodes_ips = "['${join("','",aws_instance.nodes.*.private_ip)}']"
}
locust = {
nodes_ips = join(",",aws_instance.nodes.*.private_ip)
leader_ip = local.leader_private_ip
}
k6 = {
waiting = "#"
nodes_ips = ""
}
}
executor = lookup(local.executors, var.executor, "")
waiting_command = "while [ ! -f /tmp/finished-setup ]; do echo 'waiting setup to be instaled'; sleep 5; done"
nodes_ips = local.executor.nodes_ips
}
resource "null_resource" "executor" {
count = local.auto_execute ? 1 : 0
depends_on = [
aws_instance.leader,
aws_instance.nodes
]
connection {
host = coalesce(aws_instance.leader.public_ip, aws_instance.leader.private_ip)
type = "ssh"
user = var.ssh_user
private_key = tls_private_key.loadtest.private_key_pem
}
#EXECUTE SCRIPTS
provisioner "remote-exec" {
inline = [
"echo 'START EXECUTION'",
local.waiting_command,
]
}
provisioner "remote-exec" {
inline = [
"echo DIR: ${var.loadtest_dir_destination}",
"cd ${var.loadtest_dir_destination}",
"echo PATH: $PATH",
"echo JVM_ARGS: $JVM_ARGS",
"sudo chmod 777 /var/www/html -Rf",
"sudo rm -rf /var/www/html/*",
"sudo rm -rf /loadtest/logs",
"echo ${replace(var.loadtest_entrypoint, "{NODES_IPS}", local.nodes_ips)}",
replace(var.loadtest_entrypoint, "{NODES_IPS}", local.nodes_ips)
]
}
# triggers = {
# always_run = timestamp()
# }
}