From d93960056189977634c08b10474b7d12953fc9f8 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Mon, 7 Feb 2022 22:50:44 +0100 Subject: [PATCH] Avoid connection timeout errors while waiting for reboot --- agents.tf | 8 +++++++- master.tf | 8 +++++++- servers.tf | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/agents.tf b/agents.tf index b0610d7..ad65ec8 100644 --- a/agents.tf +++ b/agents.tf @@ -50,7 +50,13 @@ resource "hcloud_server" "agents" { # Wait for MicroOS to reboot and be ready provisioner "local-exec" { - command = "ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 10 && until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done" + command = <<-EOT + until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true 2> /dev/null + do + echo Waiting for ssh to be ready... + sleep 2 + done + EOT } # Generating and uploading the angent.conf file diff --git a/master.tf b/master.tf index 0e2bdfd..33fbf57 100644 --- a/master.tf +++ b/master.tf @@ -48,7 +48,13 @@ resource "hcloud_server" "first_control_plane" { # Wait for MicroOS to reboot and be ready provisioner "local-exec" { - command = "ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 10 && until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done" + command = <<-EOT + until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true 2> /dev/null + do + echo Waiting for ssh to be ready... + sleep 2 + done + EOT } # Generating k3s master config file diff --git a/servers.tf b/servers.tf index 9531bac..3cbdc68 100644 --- a/servers.tf +++ b/servers.tf @@ -49,7 +49,13 @@ resource "hcloud_server" "control_planes" { # Wait for MicroOS to reboot and be ready provisioner "local-exec" { - command = "ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 10 && until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done" + command = <<-EOT + until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true 2> /dev/null + do + echo Waiting for ssh to be ready... + sleep 2 + done + EOT } # Generating k3s server config file