vcard4reseller/deploy/terraform/deploy.tf
Thomas Peterson 936e25e162 Deploy: git safe.directory für Rollout setzen
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 19:37:00 +02:00

31 lines
1.0 KiB
HCL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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",
]
}
}