-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.tf
71 lines (61 loc) · 2.12 KB
/
main.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
provider "openstack" {
cloud = var.cloud
}
## REMOTE STATE
# terraform {
# backend "swift" {}
# }
# Run this to set the required backend options:
#-------------------------------------------------
# terraform init \
# -backend-config="cloud=training-lf-kubernetes" \
# -backend-config="container=training-lf-kubernetes-terraform-state" \
# -backend-config="archive_container=training-lf-kubernetes-terraform-state-archive" \
# -backend-config="state_name=terraform-$TRAINER_NAME.stat"
module "network" {
source = "./modules/network"
trainer = var.trainer
course_type = var.course_type
network_range = var.network_range
}
module "student_workspace" {
source = "./modules/student_workspace"
students = var.students
instances = var.instances
network = module.network.network_id
machine_type = var.machine_type
course_type = var.course_type
trainer = var.trainer
dns_domain = var.dns_domain
sec_groups = [module.network.secgroup_name]
solutions_url = var.solutions_url
solutions_patch = fileexists("${path.module}/solutions.patch") ? filebase64("${path.module}/solutions.patch") : ""
ubuntu_image = var.ubuntu_image
depends_on = [module.network]
}
module "wetty_server" {
count = var.wetty_config.enabled ? 1 : 0
source = "./modules/wetty_server"
network = module.network.network_id
machine_type = var.machine_type
course_type = var.course_type
trainer = var.trainer
sec_groups = [module.network.secgroup_name]
instances = module.student_workspace.instance_info
ubuntu_image = var.ubuntu_image
dns_domain = var.dns_domain
trainer_email = var.wetty_config.trainer_email
}
resource "null_resource" "cluster" {
triggers = {
ips = "${module.student_workspace.ips_checksum}"
keys = "${module.student_workspace.keys_checksum}"
passwords = join(",", flatten(module.wetty_server.*.student_passwords_hash))
}
provisioner "local-exec" {
command = "./scripts/create_package.sh"
}
}
output "wetty_server_address" {
value = module.wetty_server.*.wetty_server_address
}