Fail early

36 views
Skip to first unread message

Daryl Wood

unread,
Apr 1, 2016, 4:39:00 PM4/1/16
to Vagrant
Hi,

I want the vagrantfile script to fail early if the box cannot be downloaded due to a proxy or firewall.

What's the best way to make that happen?

Thanks

Alvaro Miranda Aguilera

unread,
Apr 2, 2016, 6:16:11 AM4/2/16
to vagra...@googlegroups.com
Hello

if there is no connectivity to download the box, then on vagrant up will fail.

not sure how you can make it fail earlier.

Can you describe what you see today ?

If someone copy a project of yours, and and then do vagrant up, it should fail very soon if can't download the box.

Thanks
Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/49a6f145-fa8a-4232-b435-f3c623e1d30d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dragon788

unread,
Apr 2, 2016, 8:09:13 PM4/2/16
to Vagrant
You could potentially run a test ping inside the ruby before the vagrant section against the atlas.hashicorp.com website and if you can't reach it simply exit instead of going on.

Daryl Wood

unread,
Apr 5, 2016, 7:58:50 PM4/5/16
to Vagrant
Thanks for the reply,

The box fails if it cannot connect to atlas.hashicorp.com, as it should, but I want to handle the error.

dragon788

unread,
Apr 7, 2016, 3:03:42 PM4/7/16
to Vagrant
You should be able to run an arbitrary command from within the Vagrantfile (its just Ruby) so you could try a 
ping = `ping -c 3 atlas.hashicorp.com || false`
if ping
 
<dosomething>
else
puts
"Proxy or network issue detected, aborting"
exit 1

This is not valid Ruby (I'm a Python guy mostly) but it gives you a general idea.
Reply all
Reply to author
Forward
0 new messages