forked from kube-hetzner/terraform-hcloud-kube-hetzner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kustomization_user.tf
44 lines (37 loc) · 1.18 KB
/
kustomization_user.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
locals {
user_kustomization_exists = fileexists("extra-manifests/kustomization.yaml.tpl")
user_kustomization_files = toset([for p in fileset("extra-manifests", "**") : p if p != "kustomization.yaml.tpl"])
}
resource "null_resource" "kustomization_user" {
count = local.user_kustomization_exists ? 1 : 0
connection {
user = "root"
private_key = var.ssh_private_key
agent_identity = local.ssh_agent_identity
host = module.control_planes[keys(module.control_planes)[0]].ipv4_address
port = var.ssh_port
}
provisioner "remote-exec" {
inline = [
"echo 'Create kustomize dir'",
"mkdir -p /var/user_kustomize"
]
}
provisioner "file" {
source = "extra-manifests/"
destination = "/var/user_kustomize"
}
provisioner "file" {
content = templatefile("extra-manifests/kustomization.yaml.tpl", var.extra_kustomize_parameters)
destination = "/var/user_kustomize/kustomization.yaml"
}
provisioner "remote-exec" {
inline = [
"rm /var/user_kustomize/kustomization.yaml.tpl",
"kubectl apply -k /var/user_kustomize/"
]
}
depends_on = [
null_resource.kustomization,
]
}