-
Notifications
You must be signed in to change notification settings - Fork 2
/
dcos.tf
126 lines (120 loc) · 3.73 KB
/
dcos.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
provider "scaleway" {
organization = "${var.organization_key}"
access_key = "${var.secret_key}"
region = "${var.region}"
}
resource "scaleway_server" "dcos_bootstrap" {
name = "${format("${var.dcos_cluster_name}-bootstrap-%02d", count.index)}"
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_boot_type}"
connection {
user = "${var.user}"
private_key = "${file(var.dcos_ssh_key_path)}"
}
provisioner "local-exec" {
command = "rm -rf ./scw-install.sh"
}
provisioner "local-exec" {
command = "echo BOOTSTRAP=\"${scaleway_server.dcos_bootstrap.public_ip}\" >> ips.txt"
}
provisioner "local-exec" {
command = "echo CLUSTER_NAME=\"${var.dcos_cluster_name}\" >> ips.txt"
}
provisioner "remote-exec" {
inline = [
"wget -q -O dcos_generate_config.sh -P $HOME ${var.dcos_installer_url}",
"mkdir $HOME/genconf"
]
}
provisioner "local-exec" {
command = "./make-files.sh"
}
provisioner "local-exec" {
command = "sed -i -e '/^- *$/d' ./config.yaml"
}
provisioner "file" {
source = "./ip-detect"
destination = "$HOME/genconf/ip-detect"
}
provisioner "file" {
source = "./config.yaml"
destination = "$HOME/genconf/config.yaml"
}
provisioner "remote-exec" {
inline = ["sudo bash $HOME/dcos_generate_config.sh",
"docker run -d -p 4040:80 -v $HOME/genconf/serve:/usr/share/nginx/html:ro nginx 2>/dev/null",
"docker run -d -p 2181:2181 -p 2888:2888 -p 3888:3888 --name=dcos_int_zk jplock/zookeeper 2>/dev/null"
]
}
}
resource "scaleway_server" "dcos_master" {
name = "${format("${var.dcos_cluster_name}-master-%02d", count.index)}"
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_master_type}"
count = "${var.dcos_master_count}"
connection {
user = "${var.user}"
private_key = "${file(var.dcos_ssh_key_path)}"
}
provisioner "local-exec" {
command = "rm -rf ./scw-install.sh"
}
provisioner "local-exec" {
command = "echo ${format("MASTER_%02d", count.index)}=\"${self.public_ip}\" >> ips.txt"
}
provisioner "local-exec" {
command = "while [ ! -f ./scw-install.sh ]; do sleep 1; done"
}
provisioner "file" {
source = "./scw-install.sh"
destination = "/tmp/scw-install.sh"
}
provisioner "remote-exec" {
inline = "bash /tmp/scw-install.sh master"
}
}
resource "scaleway_server" "dcos_agent" {
name = "${format("${var.dcos_cluster_name}-agent-%02d", count.index)}"
depends_on = ["scaleway_server.dcos_bootstrap"]
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_agent_type}"
count = "${var.dcos_agent_count}"
connection {
user = "${var.user}"
private_key = "${file(var.dcos_ssh_key_path)}"
}
provisioner "local-exec" {
command = "while [ ! -f ./scw-install.sh ]; do sleep 1; done"
}
provisioner "file" {
source = "scw-install.sh"
destination = "/tmp/scw-install.sh"
}
provisioner "remote-exec" {
inline = "bash /tmp/scw-install.sh slave"
}
}
resource "scaleway_server" "dcos_public_agent" {
name = "${format("${var.dcos_cluster_name}-public-agent-%02d", count.index)}"
depends_on = ["scaleway_server.dcos_bootstrap"]
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_agent_type}"
connection {
user = "${var.user}"
private_key = "${file(var.dcos_ssh_key_path)}"
}
provisioner "local-exec" {
command = "while [ ! -f ./scw-install.sh ]; do sleep 1; done"
}
provisioner "file" {
source = "scw-install.sh"
destination = "/tmp/scw-install.sh"
}
provisioner "remote-exec" {
inline = "bash /tmp/scw-install.sh slave_public"
}
}