From 4ee2156a951ae3ba4291fe9a2ad4e5c566d23b24 Mon Sep 17 00:00:00 2001 From: phaer Date: Mon, 21 Feb 2022 16:18:11 +0100 Subject: [PATCH] wait for load-balancer in null-resource... ...because we can only do that whenever the cluster is operational, which it isn't with just one node. --- main.tf | 37 ++++++++++++++++++++++++++++++++++++- master.tf | 9 +-------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/main.tf b/main.tf index d0eb508..7437d2f 100644 --- a/main.tf +++ b/main.tf @@ -156,5 +156,40 @@ resource "hcloud_placement_group" "k3s" { data "hcloud_load_balancer" "traefik" { name = "traefik" - depends_on = [module.first_control_plane] + depends_on = [null_resource.cluster_provisioning] +} + + +resource "null_resource" "cluster_provisioning" { + + triggers = { + agent_ids = "${join(",", module.agents.*.id)}" + control_plane_ids = "${join(",", concat([module.first_control_plane.id], module.control_planes.*.id))}" + } + + depends_on = [ null_resource.first_control_plane, null_resource.control_planes, null_resource.agents ] + + provisioner "remote-exec" { + connection { + user = "root" + private_key = local.ssh_private_key + agent_identity = local.ssh_identity + host = module.first_control_plane.ipv4_address + } + + inline = [ + <<-EOT + timeout 120 bash <