# Code-Rollout auf die App-Nodes ohne Neu-Provisionierung. # Bei Änderung von var.deploy_version (z. B. Git-SHA) führt `tofu apply` auf jedem # App-Node ein Update aus: neuesten Code holen, SPA neu bauen, Composer/Autoloader # auffrischen, Cache leeren – Migrationen nur auf app-1. Server bleiben erhalten. resource "terraform_data" "app_deploy" { count = var.app_count triggers_replace = [var.deploy_version] depends_on = [hcloud_server.app] connection { type = "ssh" host = hcloud_server.app[count.index].ipv4_address user = "root" private_key = file(pathexpand(var.ssh_private_key_path)) timeout = "5m" } provisioner "remote-exec" { inline = [ "set -e", "cd /opt/vcard4", "git config --global --add safe.directory /opt/vcard4", "git fetch --depth 1 origin ${var.repo_branch}", "git reset --hard origin/${var.repo_branch}", "DOMAIN='${var.domain}' RUN_MIGRATIONS='${count.index == 0 ? "true" : "false"}' bash /opt/vcard4/deploy/update.sh", ] } }