diff --git a/init.tf b/init.tf index 4222f2f6..a58e0a81 100644 --- a/init.tf +++ b/init.tf @@ -73,8 +73,8 @@ resource "null_resource" "first_control_plane" { provisioner "remote-exec" { inline = [ "systemctl start k3s", - # prepare the post_install directory - "mkdir -p /var/post_install", + # prepare the needed directories + "mkdir -p /var/post_install /var/user_kustomize", # wait for k3s to become ready <<-EOT timeout 120 bash < 0 ? 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 - } - - # Create remote directory - provisioner "remote-exec" { - inline = [ - "echo 'Create new /var/user_kustomize directory...'", - "rm -rf /var/user_kustomize && mkdir -p /var/user_kustomize" - ] - } - - # Copy all files, recursively from extra-manifests/ into the /var/user_kustomize directory. - # NOTE: If non *.yaml.tpl files are changed, you need to taint this resource to re-provision the changes, - # since there is no 'triggers {}' definition that watches all files/directories for changes. - provisioner "file" { - source = "extra-manifests/" - destination = "/var/user_kustomize" - } - - depends_on = [ - null_resource.kustomization - ] -} - resource "null_resource" "kustomization_user" { for_each = local.user_kustomization_templates @@ -54,14 +22,8 @@ resource "null_resource" "kustomization_user" { manifest_sha1 = "${sha1(templatefile("extra-manifests/${each.key}", var.extra_kustomize_parameters))}" } - lifecycle { - replace_triggered_by = [ - null_resource.kustomization_user_setup - ] - } - depends_on = [ - null_resource.kustomization_user_setup[0] + null_resource.kustomization ] } @@ -81,9 +43,9 @@ resource "null_resource" "kustomization_user_deploy" { # 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'", inline = compact([ "rm -f /var/user_kustomize/*.yaml.tpl", - "echo 'Deploying manifests from /var/user_kustomize/:' && ls -alh /var/user_kustomize", - "kubectl kustomize /var/user_kustomize/ | kubectl apply --wait=true -f -", - "${var.extra_kustomize_deployment_commands}" + "echo 'Applying user kustomization...", + "kubectl apply -k /var/user_kustomize/ --wait=true", + var.extra_kustomize_deployment_commands ]) }