class Kitsune::Kit::Provisioner

def wait_for_public_ip(droplet_id, interval: 5, max_attempts: 24)

Waits until obtaining the public IP
def wait_for_public_ip(droplet_id, interval: 5, max_attempts: 24)
  max_attempts.times do |i|
    droplet = @client.droplets.find(id: droplet_id)
    if (v4 = droplet.networks.v4.find { |n| n.type == "public" })
      return v4.ip_address
    end
    puts "⏳ Waiting for public IP... (#{i + 1}/#{max_attempts})"
    sleep interval
  end
  abort "❌ Timeout: the Droplet did not obtain a public IP after #{interval * max_attempts} seconds"
end