-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.tf
76 lines (69 loc) · 1.72 KB
/
init.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
locals {
store_private_key = yamlencode({
#cloud-config
write_files = [
{
path = "root/.ssh/id_rsa"
permissions = "0600"
owner = "root:root"
content = tls_private_key.key.private_key_pem
defer = true
}]
hostname = "cp"
})
setWorkerHostname = yamlencode({
#cloud-config
hostname = "worker"
})
}
data "cloudinit_config" "workerNode" {
gzip = false
base64_encode = false
part {
content_type = "text/x-shellscript"
content = templatefile("${path.module}/config/workerNode.sh",
{
URL = var.lab_solution_url,
USER = var.lab_solution_username,
PASSWORD = var.lab_solution_password,
}
)
filename = "workerNode.sh"
}
part {
content_type = "text/cloud-config"
content = local.setWorkerHostname
}
}
data "cloudinit_config" "controlPlane" {
gzip = false
base64_encode = false
part {
content_type = "text/x-shellscript"
content = templatefile("${path.module}/config/controlPlane.sh",
{
URL = var.lab_solution_url,
USER = var.lab_solution_username,
PASSWORD = var.lab_solution_password,
WORKER_NODE = module.worker_node.private_ip,
}
)
filename = "controlPlane.sh"
}
dynamic "part" {
for_each = var.enable_registry ? [1] : []
content {
content_type = "text/x-shellscript"
content = templatefile("${path.module}/config/registry.sh",
{
WORKER_NODE = module.worker_node.private_ip,
}
)
filename = "registry.sh"
}
}
part {
content_type = "text/cloud-config"
content = local.store_private_key
}
}