@@ -2,38 +2,6 @@ locals {
2
2
user_kustomization_templates = try (fileset (" extra-manifests" , " *.yaml.tpl" ), toset ([]))
3
3
}
4
4
5
- resource "null_resource" "kustomization_user_setup" {
6
- count = length (local. user_kustomization_templates ) > 0 ? 1 : 0
7
-
8
- connection {
9
- user = " root"
10
- private_key = var. ssh_private_key
11
- agent_identity = local. ssh_agent_identity
12
- host = module. control_planes [keys (module. control_planes )[0 ]]. ipv4_address
13
- port = var. ssh_port
14
- }
15
-
16
- # Create remote directory
17
- provisioner "remote-exec" {
18
- inline = [
19
- " echo 'Create new /var/user_kustomize directory...'" ,
20
- " rm -rf /var/user_kustomize && mkdir -p /var/user_kustomize"
21
- ]
22
- }
23
-
24
- # Copy all files, recursively from extra-manifests/ into the /var/user_kustomize directory.
25
- # NOTE: If non *.yaml.tpl files are changed, you need to taint this resource to re-provision the changes,
26
- # since there is no 'triggers {}' definition that watches all files/directories for changes.
27
- provisioner "file" {
28
- source = " extra-manifests/"
29
- destination = " /var/user_kustomize"
30
- }
31
-
32
- depends_on = [
33
- null_resource. kustomization
34
- ]
35
- }
36
-
37
5
resource "null_resource" "kustomization_user" {
38
6
for_each = local. user_kustomization_templates
39
7
@@ -54,14 +22,8 @@ resource "null_resource" "kustomization_user" {
54
22
manifest_sha1 = " ${ sha1 (templatefile (" extra-manifests/${ each . key } " , var. extra_kustomize_parameters ))} "
55
23
}
56
24
57
- lifecycle {
58
- replace_triggered_by = [
59
- null_resource. kustomization_user_setup
60
- ]
61
- }
62
-
63
25
depends_on = [
64
- null_resource. kustomization_user_setup [ 0 ]
26
+ null_resource. kustomization
65
27
]
66
28
}
67
29
@@ -81,9 +43,9 @@ resource "null_resource" "kustomization_user_deploy" {
81
43
# Debugging: "sh -c 'for file in $(find /var/user_kustomize -type f -name \"*.yaml\" | sort -n); do echo \"\n### Template $${file}.tpl after rendering:\" && cat $${file}; done'",
82
44
inline = compact ([
83
45
" rm -f /var/user_kustomize/*.yaml.tpl" ,
84
- " echo 'Deploying manifests from /var/user_kustomize/:' && ls -alh /var/user_kustomize " ,
85
- " kubectl kustomize /var/user_kustomize/ | kubectl apply --wait=true -f - " ,
86
- " ${ var . extra_kustomize_deployment_commands } "
46
+ " echo 'Applying user kustomization... " ,
47
+ " kubectl apply -k /var/user_kustomize/ --wait=true" ,
48
+ var . extra_kustomize_deployment_commands
87
49
])
88
50
}
89
51
0 commit comments