File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 11locals {
22 source_folder_files = try (fileset (var. source_folder , " **/*.tpl" ), toset ([]))
3+
34 source_files_sha = join (" " , [
45 for file_path in local . source_folder_files :
56 filesha1 (" ${ var . source_folder } /${ file_path } " )
67 ])
8+
79 parameters_sha = sha1 (jsonencode (var. template_parameters ))
810 pre_commands_string_sha = sha1 (var. pre_commands_string )
911 post_commands_string_sha = sha1 (var. post_commands_string )
Original file line number Diff line number Diff line change 22# Purpose of this module is to copy a single user kustomization "set" to control plane.
33# The set contains the yaml-files for Kustomization and the postinstall.sh script.
44
5- resource "null_resource" "create_target_directory " {
5+ resource "null_resource" "install_scripts " {
66
77 triggers = {
88 source_files_sha = local.source_files_sha
@@ -42,11 +42,11 @@ resource "null_resource" "create_target_directory" {
4242}
4343
4444resource "null_resource" "user_kustomization_template_files" {
45- for_each = local. source_folder_files
45+ for_each = nonsensitive ( local. source_folder_files )
4646
4747 lifecycle {
4848 replace_triggered_by = [
49- null_resource. create_target_directory
49+ null_resource. install_scripts
5050 ]
5151 }
5252
@@ -63,10 +63,16 @@ resource "null_resource" "user_kustomization_template_files" {
6363 bastion_private_key = var. ssh_connection . bastion_private_key
6464 }
6565
66+ provisioner "remote-exec" {
67+ inline = [
68+ " mkdir -p $(dirname \" ${ var . destination_folder } /${ each . key } \" )"
69+ ]
70+ }
71+
6672 provisioner "file" {
6773 content = templatefile (" ${ var . source_folder } /${ each . key } " , var. template_parameters )
6874 destination = replace (" ${ var . destination_folder } /${ each . key } " , " .tpl" , " " )
6975 }
7076
71- depends_on = [null_resource. create_target_directory ]
77+ depends_on = [null_resource. install_scripts ]
7278}
Original file line number Diff line number Diff line change 44module "user_kustomization_set" {
55 source = " ../user_kustomization_set"
66
7- for_each = var. kustomizations_map
7+ for_each = nonsensitive ( toset ( keys ( var. kustomizations_map )))
88
99 ssh_connection = var. ssh_connection
1010
11- source_folder = each. value . source_folder
11+ source_folder = var . kustomizations_map [ each . key ] . source_folder
1212 destination_folder = " ${ local . base_destination_folder } /${ each . key } "
13- template_parameters = each. value . kustomize_parameters
13+ template_parameters = var . kustomizations_map [ each . key ] . kustomize_parameters
1414
15- pre_commands_string = each. value . pre_commands
16- post_commands_string = each. value . post_commands
15+ pre_commands_string = var . kustomizations_map [ each . key ] . pre_commands
16+ post_commands_string = var . kustomizations_map [ each . key ] . post_commands
1717}
1818
1919resource "null_resource" "kustomization_user_deploy" {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ variable "kustomizations_map" {
2424 default = {}
2525 description = " Map of kustomization entries, where key is the order number."
2626 sensitive = true
27+
2728 validation {
2829 condition = alltrue ([
2930 for key in keys (var. kustomizations_map ) :
You can’t perform that action at this time.
0 commit comments