Need ability to specify multiple vm.network settings in vagrant_options
Opened this issue · 0 comments
steversmith commented
We have a requirement to specify multiple vm.network settings in our vagrant_options. For example, setting a private network IP address, as well as setting a forwarded port.
Setting up an options hash with multiple vm.network settings will not work, since the resulting hash will only include the last setting:
options = {
vagrant_options: {
'vm.box' => 'redhat',
'vm.network' => ':private_network, {ip: "192.168.33.34"}',
'vm.network' => ':forwarded_port, guest: 27017, host: 27117'
}
}
machine 'somemachine' do
machine_options options
end
Produces the following vagrant file, which does not include both settings (e.g. the private_network setting):
Vagrant.configure('2') do |outer_config|
outer_config.vm.define "somemachine" do |config|
config.vm.box = "redhat"
config.vm.network(:forwarded_port, guest: 27017, host: 27117)
config.vm.hostname = "somemachine"
end
end
Using a multi-valued setting for the vm.network setting also does not work since Vagrant does not handle a setting with multiple values (e.g. an array).
options = {
vagrant_options: {
'vm.box' => 'redhat',
'vm.network' => [
':private_network, {ip: "192.168.33.34"}',
':forwarded_port, guest: 27017, host: 27117'
]
}
}
machine 'somemachine' do
machine_options options
end
Produces the following vagrant file, which causes vagrant to fail:
Vagrant.configure('2') do |outer_config|
outer_config.vm.define "somemachine" do |config|
config.vm.box = "redhat"
config.vm.network([":private_network, {ip: \"192.168.33.34\"}", ":forwarded_port, guest: 27017, host: 27117"])
config.vm.hostname = "somemachine"
end
end
The vagrant failure:
RuntimeError
------------
vagrant up somemachine --provider virtualbox failed!
STDOUT:
STDERR:c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/kernel_v2/config/vm.rb:231:in `network': undefined method `to_sym' for #<Array:0x43c5f78> (NoMethodError)
from c:/users/chq-steves/expeditors/cespoc/central-event-store-demo/cfg/vms/somemachine.vm:4:in `block (3 levels) in <top (required)>'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/v2/loader.rb:37:in `call'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/v2/loader.rb:37:in `load'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:103:in `block (2 levels) in load'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:97:in `each'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:97:in `block in load'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:94:in `each'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:94:in `load'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:149:in `machine_config'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:45:in `machine'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:614:in `machine'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:168:in `block in with_target_vms'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `call'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `block in with_target_vms'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `each'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `with_target_vms'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:74:in `block in execute'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:277:in `block (2 levels) in batch'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `tap'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `block in batch'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `synchronize'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `batch'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:58:in `execute'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
from c:/DevTools/Vagrant/embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'