loafoe/terraform-provider-ssh

Add support for retries after connection failures

Closed this issue · 1 comments

Sometimes you're provisioning a VM that hasn't had enough time to boot. It would be a nice feature for terraform-provider-ssh to retry in the face of connection refused/timeout.

Something like:

resource "ssh_resource" "bootstrap" {
  host        = var.host
  user        = var.user
  agent       = true
  retry_for   = "5m"
  retry_delay = "10s"
  commands = [
    "/tmp/bootstrap.sh",
  ]
}

The retry_for and retry_delay values above are perhaps sensible defaults, although if backward compatibility with current behavior is important then retry_for could default to 0.

Alternatively, if retrying in the face of connection issues is a sensible default, you could drop retry_for altogether, include the time-to-connect in the current timeout argument. In this case, retry_delay is probably still a desirable configurable.

This is implemented in version 2.3.0