ruby - Vagrant provider specific variables -


in vagrantfile set provider specific variables. after realising cannot set values in these sections (because of this):

config.vm.provider "virtualbox" |vb, override|     ... end 

... workaround - set environment variable can check , set provider settings accordingly:

  if env['vagrant_provider'] == 'virtualbox'      config.hostmanager.enabled = true     tld = "local"     dbadmin_pass = "vagrant"    elsif env['vagrant_provider'] == 'aws'      config.hostmanager.enabled = false     tld = "com"     dbadmin_pass = "myprodpass"     else      raise vagrant::errors::vagranterror.new, "missing environment variable or invalid value: vagrant_provider [virtualbox|aws]"    end 

this hacky though , requires me set environment variable well.

i'm not ruby expert @ - there better way set provider specific variables?

you can define providers like:

config.vm.provider "virtualbox" |vb|     config.hostmanager.enabled = true     tld = "local"     dbadmin_pass = "vagrant" end  config.vm.provider :aws |aws|     config.hostmanager.enabled = false     tld = "com"     dbadmin_pass = "myprodpass"  end 

then start vagrant with:

vagrant --provider=virtualbox 

or

vagrant --provider=aws 

make sure override provider specific variables, see vagrant docs - overriding configuration section.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -