-
Notifications
You must be signed in to change notification settings - Fork 2
/
agents.tf
46 lines (39 loc) · 1.31 KB
/
agents.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
#Agents Server
resource "scaleway_server" "agent" {
count = "${var.instance_agents_count}"
image = "${data.scaleway_image.image.id}"
type = "${var.instance_agents_type}"
name = "${var.prefix}-agent-${count.index}"
security_group = "${scaleway_security_group.allow_all.id}"
dynamic_ip_required = true
}
resource "null_resource" "join_node" {
depends_on = ["data.external.join_token"]
count = "${var.instance_agents_count}"
connection {
type = "ssh"
host = "${element(scaleway_server.agent.*.public_ip, count.index)}"
user = "${var.ssh_user}"
port = "${var.ssh_port}"
private_key = "${local.ssh_private}"
}
provisioner "remote-exec" {
inline = [
# "apt-get update",
# "DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes",
# "DEBIAN_FRONTEND=noninteractive apt-get install open-iscsi --yes",
"${data.template_file.agent.rendered}"
]
}
}
data "template_file" "agent" {
template = "${file("files/agent_install.sh")}"
vars = {
server_ip = "${scaleway_server.master.public_ip}"
token = "${data.external.join_token.result.token}"
}
}
data "external" "join_token" {
depends_on = ["null_resource.copy_configs"]
program = ["./files/fetch-token.sh"]
}