diff --git a/lib/vagrant-digitalocean/actions/create.rb b/lib/vagrant-digitalocean/actions/create.rb index 4b5d9d6..1377708 100644 --- a/lib/vagrant-digitalocean/actions/create.rb +++ b/lib/vagrant-digitalocean/actions/create.rb @@ -41,8 +41,13 @@ def call(env) @machine.id = result['droplet']['id'].to_s # refresh droplet state with provider and output ip address - droplet = Provider.droplet(@machine, :refresh => true) - public_network = droplet['networks']['v4'].find { |network| network['type'] == 'public' } + droplet = nil + public_network = nil + retryable(:tries => 10, :sleep => 5) do + droplet = Provider.droplet(@machine, :refresh => true) + public_network = droplet['networks']['v4'].find { |network| network['type'] == 'public' } + raise 'Public network IP not yet available' unless public_network && public_network['ip_address'] + end private_network = droplet['networks']['v4'].find { |network| network['type'] == 'private' } env[:ui].info I18n.t('vagrant_digital_ocean.info.droplet_ip', :ip => public_network['ip_address']) if private_network