-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
232 lines (211 loc) · 7.33 KB
/
main.tf
File metadata and controls
232 lines (211 loc) · 7.33 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
terraform {
required_version = ">= 1.4.0"
}
variable "pool" {
description = "Slurm pool of compute nodes"
default = []
}
variable "TFC_WORKSPACE_NAME" {
type = string
}
variable "tfe_token" {
type = string
default = ""
}
variable "cloud_name" {
type = string
default = ""
}
variable "config_type" {
type = string
default = ""
}
variable "subnet_id" {
type = string
default = ""
}
variable "os_ext_network" {
type = string
default = ""
}
variable "eyaml_key" { }
variable "prometheus_password" {
type = string
default = ""
}
variable "suffix" {
type = string
default = ""
}
data "tfe_workspace" "test" {
name = var.TFC_WORKSPACE_NAME
organization = "CalculQuebec"
}
locals {
default_pod = {
user_quotas_sizes = {
home = "4g"
project = "1g"
scratch = "1g"
}
user_quotas_inodes = {
home = 100000
project = 100000
scratch = 100000
}
}
user_quotas = {
home = {
bsoft = local.default_pod.user_quotas_sizes.home
bhard = local.default_pod.user_quotas_sizes.home
isoft = local.default_pod.user_quotas_inodes.home
ihard = local.default_pod.user_quotas_inodes.home
}
project = {
bsoft = local.default_pod.user_quotas_sizes.project
bhard = local.default_pod.user_quotas_sizes.project
isoft = local.default_pod.user_quotas_inodes.project
ihard = local.default_pod.user_quotas_inodes.project
}
scratch = {
bsoft = local.default_pod.user_quotas_sizes.scratch
bhard = local.default_pod.user_quotas_sizes.scratch
isoft = local.default_pod.user_quotas_inodes.scratch
ihard = local.default_pod.user_quotas_inodes.scratch
}
}
instances_type_map = {
prod = {
mgmt = "ha2-4gb"
puppet = "ha2-4gb"
login = "ha1-2gb"
caddy = "ha1-1.25gb"
jupyter = "ha1-2gb"
cip101 = "c1-3.75gb"
node = "c1-3.75gb"
edx = "ha16-60gb"
}
test = {
mgmt = "c1-3.75gb"
puppet = "c1-3.75gb"
login = "c1-3.75gb"
caddy = "c1-3.75gb"
jupyter = "c1-3.75gb"
cip101 = "c1-3.75gb"
node = "c1-3.75gb"
edx = "c8-60gb"
}
dev = {
mgmt = "p4-7.5gb"
puppet = "p2-3.75gb"
login = "p2-3.75gb"
caddy = "p2-3.75gb"
jupyter = "p2-3.75gb"
cip101 = "c2-7.5gb"
node = "c2-7.5gb"
edx = "c8-60gb"
}
}
volumes = {
prod = {
nfs = {
home = { size = 100, quota = local.user_quotas.home, mkfs_options = "-K", enable_resize = true }
project = { size = 100, quota = local.user_quotas.project, mkfs_options = "-K", enable_resize = true }
scratch = { size = 100, quota = local.user_quotas.scratch, mkfs_options = "-K", enable_resize = true }
}
}
test = {
nfs = {
home = { size = 100, quota = local.user_quotas.home, mkfs_options = "-K", enable_resize = true }
project = { size = 100, quota = local.user_quotas.project, mkfs_options = "-K", enable_resize = true }
scratch = { size = 100, quota = local.user_quotas.scratch, mkfs_options = "-K", enable_resize = true }
}
}
dev = {
nfs = {
home = { size = 100, quota = local.user_quotas.home, mkfs_options = "-K", enable_resize = true }
project = { size = 100, quota = local.user_quotas.project, mkfs_options = "-K", enable_resize = true }
scratch = { size = 100, quota = local.user_quotas.scratch, mkfs_options = "-K", enable_resize = true }
}
}
}
image = "snapshot-cpunode-2026.1-A9.7"
}
module "openstack" {
source = "git::https://github.com/calculquebec/magic_castle_formation.git//openstack?ref=edx"
config_git_url = "https://github.com/computecanada/puppet-magic_castle.git"
config_version = "15.2.1"
cluster_name = "evolo${var.suffix}"
domain = "calculquebec.cloud"
image = "AlmaLinux-9"
instances = {
mgmt = { type = local.instances_type_map[var.config_type].mgmt, tags = ["mgmt", "nfs", "mgmt_extra"], count = 1, disk_size=100 }
puppet = { type = local.instances_type_map[var.config_type].puppet, tags = ["puppet"], count = 1 }
login = { type = local.instances_type_map[var.config_type].login, tags = ["login", "public"], count = 1}
caddy = { type = local.instances_type_map[var.config_type].caddy, tags = ["public", "proxy"], count = 1}
jupyter = { type = local.instances_type_map[var.config_type].jupyter, tags = ["jupyterhub"], count = 1}
cip101- = { type = local.instances_type_map[var.config_type].cip101, tags = ["node", "pool"], feature = ["cip101"], image = local.image, count = 5 }
node = { type = local.instances_type_map[var.config_type].node, tags = ["node"], count = 0 }
nodepool = { type = local.instances_type_map[var.config_type].node, tags = ["node", "pool"], image = local.image, count = 5 }
evolo = { type = local.instances_type_map[var.config_type].login, tags = ["internal_login"], count = 1 }
edx = { type = local.instances_type_map[var.config_type].edx, tags = ["edx"], count = 1, disk_size = 500 }
}
# var.pool is managed by Slurm through Terraform REST API.
# To let Slurm manage a type of nodes, add "pool" to its tag list.
# When using Terraform CLI, this parameter is ignored.
# Refer to Magic Castle Documentation - Enable Magic Castle Autoscaling
pool = var.pool
volumes = local.volumes[var.config_type]
public_keys = compact(concat(split("\n", file("keys/sshkeys.pub")), ))
nb_users = 1
# Shared password, randomly chosen if blank
guest_passwd = ""
hieradata = yamlencode(merge(
{
"profile::slurm::controller::tfe_workspace" = data.tfe_workspace.test.id
"profile::slurm::controller::tfe_token" = var.tfe_token
"suffix" = var.suffix
"cluster_name" = "evolo${var.suffix}"
"prometheus_password" = var.prometheus_password
"cloud_name" = var.cloud_name
},
yamldecode(file("config.yaml")),
))
hieradata_dir = "hieradata${var.suffix}"
software_stack = "alliance"
eyaml_key = base64decode(var.eyaml_key)
subnet_id = "${var.subnet_id}"
os_ext_network = "${var.os_ext_network}"
puppetfile = file("Puppetfile")
}
output "accounts" {
value = module.openstack.accounts
}
output "public_ip" {
value = module.openstack.public_ip
}
## Uncomment to register your domain name with CloudFlare
module "dns" {
source = "git::https://github.com/calculquebec/magic_castle_formation.git//dns/cloudflare?ref=edx"
name = module.openstack.cluster_name
domain = module.openstack.domain
public_instances = module.openstack.public_instances
domain_tag = "proxy"
vhosts = ["*.edx", "edx", "ipa", "jupyter", "mokey", "explore"]
dkim_public_key = file("keys/dkim_public.pem")
}
## Uncomment to register your domain name with Google Cloud
# module "dns" {
# source = "./dns/gcloud"
# project = "your-project-id"
# zone_name = "you-zone-name"
# name = module.openstack.cluster_name
# domain = module.openstack.domain
# bastions = module.openstack.bastions
# public_instances = module.openstack.public_instances
# ssh_private_key = module.openstack.ssh_private_key
# sudoer_username = module.openstack.accounts.sudoer.username
# }
# output "hostnames" {
# value = module.dns.hostnames
# }