I'm trying to do something like the following to set a default value if an environment variable is not set:
config.vm.box = ENV['VAGRANT_DEV_BOX'] || "ubuntu/xenial64"
Which causes the following error:
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/version.rb:208:in `initialize': Malformed version number string debian-VAGRANTSLASH-jessie64 (ArgumentError)
The VAGRANT_DEV_BOX
variable hasn't been set at this point. Confirmed like so:
server 🦄 echo $VAGRANT_DEV_BOX
server 🦄
Is it possible to do this in Ruby and/or Vagrantfile?
This is thanks to double-p
on #vagrant, freenode:
<double-p>
you cannot just inline ruby.. put this above vagrant-configure, like:
port = ENV["HOST_PORT"] || 8080
Vagrant.configure("2") do |config|
# Ubuntu 14.04 LTS
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: port
config.vm.provision "shell", path: "vagrant/provision.sh"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With