-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstack.tf
151 lines (124 loc) · 4.04 KB
/
stack.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
data "template_file" "traefik" {
template = "${file("${path.module}/assets/traefik/traefik.tpl")}"
vars {
domain = "${var.domain}"
}
}
data "template_file" "vocab" {
template = "${file("${path.module}/assets/traefik/vocab.tpl")}"
vars {
domain = "${var.domain}"
}
}
data "template_file" "stack" {
template = "${file("${path.module}/stacks/core/swarm-compose.tpl")}"
vars {
domain = "${var.domain}"
version = "${var.version}"
godaddy_api_key = "${var.godaddy_api_key}"
godaddy_api_secret = "${var.godaddy_api_secret}"
dataone_url = "${var.dataone_url}"
}
}
resource "null_resource" "label_nodes" {
depends_on = ["null_resource.provision_worker", "null_resource.provision_fileserver"]
connection {
user = "${var.ssh_user_name}"
private_key = "${file("${var.ssh_key_file}")}"
host = "${openstack_networking_floatingip_v2.swarm_manager_ip.address}"
}
provisioner "file" {
source = "./scripts/label-nodes.sh"
destination = "/tmp/label-nodes.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/label-nodes.sh",
"/tmp/label-nodes.sh ${var.cluster_name}-nfs"
]
}
}
resource "null_resource" "deploy_stack" {
depends_on = ["null_resource.label_nodes", "null_resource.provision_fileserver"]
connection {
user = "${var.ssh_user_name}"
private_key = "${file("${var.ssh_key_file}")}"
host = "${openstack_networking_floatingip_v2.swarm_manager_ip.address}"
}
provisioner "remote-exec" {
inline = [
"mkdir -p /home/ubuntu/wholetale/traefik/acme"
]
}
provisioner "file" {
source = "assets/traefik/acme/acme.json"
destination = "/home/ubuntu/wholetale/traefik/acme/acme.json"
}
provisioner "file" {
content = "${data.template_file.stack.rendered}"
destination = "/home/ubuntu/wholetale/swarm-compose.yaml"
}
provisioner "file" {
source = "stacks/monitoring/monitoring.yaml"
destination = "/home/ubuntu/wholetale/monitoring.yaml"
}
provisioner "file" {
content = "${data.template_file.traefik.rendered}"
destination = "/home/ubuntu/wholetale/traefik/traefik.toml"
}
provisioner "file" {
content = "${data.template_file.vocab.rendered}"
destination = "/home/ubuntu/wholetale/traefik/vocab.toml"
}
provisioner "file" {
source = "scripts/start-worker.sh"
destination = "/home/ubuntu/wholetale/start-worker.sh"
}
provisioner "file" {
source = "scripts/init-mongo.sh"
destination = "/home/ubuntu/wholetale/init-mongo.sh"
}
provisioner "remote-exec" {
inline = [
"chmod 600 /home/ubuntu/wholetale/traefik/acme/acme.json",
"docker stack deploy --compose-file /home/ubuntu/wholetale/swarm-compose.yaml wt",
"docker stack deploy --compose-file /home/ubuntu/wholetale/monitoring.yaml omd"
]
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/wholetale/init-mongo.sh",
"/home/ubuntu/wholetale/init-mongo.sh ${var.domain} ${var.globus_client_id} ${var.globus_client_secret}"
]
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/wholetale/start-worker.sh",
"/home/ubuntu/wholetale/start-worker.sh ${var.domain} manager ${var.registry_user} ${var.registry_pass} ${var.version} ${var.matlab_file_installation_key}"
]
}
}
resource "null_resource" "start_worker" {
count = "${var.num_workers}"
depends_on = ["null_resource.deploy_stack"]
connection {
user = "${var.ssh_user_name}"
private_key = "${file("${var.ssh_key_file}")}"
host = "${element(openstack_networking_floatingip_v2.swarm_worker_ip.*.address, count.index)}"
}
provisioner "remote-exec" {
inline = [
"mkdir -p /home/ubuntu/wholetale/"
]
}
provisioner "file" {
source = "scripts/start-worker.sh"
destination = "/home/ubuntu/wholetale/start-worker.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ubuntu/wholetale/start-worker.sh",
"/home/ubuntu/wholetale/start-worker.sh ${var.domain} celery ${var.registry_user} ${var.registry_pass} ${var.version}"
]
}
}