diff options
author | varac <varacanero@zeromail.org> | 2013-07-26 19:31:24 +0200 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2013-07-26 19:31:24 +0200 |
commit | d188d599de9997db4c905ae252c4efcba9d7d432 (patch) | |
tree | 93f867aecc505f216661fcc7582d26cf16e7ca69 /lib/leap_cli/commands | |
parent | 9383ae3fb4094a328459971aaedb6b43fa6d17cf (diff) | |
parent | 7b8ae68306108498ce9ea736a9e102c3ce103393 (diff) |
Merge branch 'issue_2496'
Diffstat (limited to 'lib/leap_cli/commands')
-rw-r--r-- | lib/leap_cli/commands/vagrant.rb | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/lib/leap_cli/commands/vagrant.rb b/lib/leap_cli/commands/vagrant.rb index 032fa36..610574d 100644 --- a/lib/leap_cli/commands/vagrant.rb +++ b/lib/leap_cli/commands/vagrant.rb @@ -146,18 +146,41 @@ module LeapCli; module Commands def create_vagrant_file lines = [] netmask = IPAddr.new('255.255.255.255').mask(LeapCli.leapfile.vagrant_network.split('/').last).to_s - lines << %[Vagrant::Config.run do |config|] - manager.each_node do |node| - if node.vagrant? - lines << %[ config.vm.define :#{node.name} do |config|] - lines << %[ config.vm.box = "leap-wheezy"] - lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] - lines << %[ config.vm.network :hostonly, "#{node.ip_address}", :netmask => "#{netmask}"] - lines << %[ config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] - lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line - lines << %[ end] - end - end + + version = vagrant_version + case version + when 0..1 + lines << %[Vagrant::Config.run do |config|] + manager.each_node do |node| + if node.vagrant? + lines << %[ config.vm.define :#{node.name} do |config|] + lines << %[ config.vm.box = "leap-wheezy"] + lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] + lines << %[ config.vm.network :hostonly, "#{node.ip_address}", :netmask => "#{netmask}"] + lines << %[ config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] + lines << %[ config.vm.customize ["modifyvm", :id, "--name", "#{node.name}"]] + lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line + lines << %[ end] + end + end + when 2 + lines << %[Vagrant.configure("2") do |config|] + manager.each_node do |node| + if node.vagrant? + lines << %[ config.vm.define :#{node.name} do |config|] + lines << %[ config.vm.box = "leap-wheezy"] + lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] + lines << %[ config.vm.network :private_network, ip: "#{node.ip_address}"] + lines << %[ config.vm.provider "virtualbox" do |v|] + lines << %[ v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] + lines << %[ v.name = "#{node.name}"] + lines << %[ end] + lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line + lines << %[ end] + end + end + end + lines << %[end] lines << "" write_file! :vagrantfile, lines.join("\n") |