vagrant: stop rsync from wiping changes from /vpp
[vpp.git] / build-root / vagrant / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 Vagrant.configure(2) do |config|
5
6   # Pick the right distro and bootstrap, default is ubuntu1404
7   distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1404")
8   if distro == 'centos7'
9     config.vm.box = "puppetlabs/centos-7.2-64-nocm"
10     config.ssh.insert_key = false
11   else
12     config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
13   end
14   config.vm.box_check_update = false
15
16   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
17   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
18   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh"), :args => "/vpp"
19   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
20   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"run.sh")
21
22   # Add .gnupg dir in so folks can sign patches
23   # Note, as gnupg puts socket files in that dir, we have
24   # to be cautious and make sure we are dealing with a plain file
25   homedir = File.expand_path("~/")
26   Dir["#{homedir}/.gnupg/**/*"].each do |fname|
27     if File.file?(fname)
28       destname = fname.sub(Regexp.escape("#{homedir}/"),'')
29       config.vm.provision "file", source: fname, destination: destname
30     end
31   end
32
33   # Copy in the .gitconfig if it exists
34   if File.file?(File.expand_path("~/.gitconfig"))
35     config.vm.provision  "file", source: "~/.gitconfig", destination: ".gitconfig"
36   end
37
38   # vagrant-cachier caches apt/yum etc to speed subsequent
39   # vagrant up
40   # to enable, run
41   # vagrant plugin install vagrant-cachier
42   #
43   if Vagrant.has_plugin?("vagrant-cachier")
44     config.cache.scope = :box
45   end
46
47   # Define some physical ports for your VMs to be used by DPDK
48   nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
49   for i in 1..nics
50     config.vm.network "private_network", type: "dhcp"
51   end
52
53   # use http proxy if avaiable
54   if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
55    config.proxy.http     = ENV['http_proxy']
56    config.proxy.https    = ENV['https_proxy']
57    config.proxy.no_proxy = "localhost,127.0.0.1"
58   end
59
60   vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
61   vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
62
63   config.ssh.forward_agent = true
64
65   config.vm.provider "virtualbox" do |vb|
66       vb.customize ["modifyvm", :id, "--ioapic", "on"]
67       vb.memory = "#{vmram}"
68       vb.cpus = "#{vmcpu}"
69
70       # rsync the vpp directory if provision hasn't happened yet
71       unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
72         config.vm.synced_folder "../../", "/vpp", type: "rsync",
73          rsync__auto: false,
74          rsync__exclude: [
75           "build-root/build*/",
76           "build-root/install*/",
77           "build-root/images*/",
78           "build-root/*.deb",
79           "build-root/*.rpm",
80           "build-root/*.changes",
81           "build-root/python",
82           "build-root/deb/debian/*.dkms",
83           "build-root/deb/debian/*.install",
84           "build-root/deb/debian/changes",
85           "build-root/tools"]
86       end
87
88       #support for the SSE4.x instruction is required in some versions of VB.
89       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
90       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
91   end
92   config.vm.provider "vmware_fusion" do |fusion,override|
93     fusion.vmx["memsize"] = "#{vmram}"
94     fusion.vmx["numvcpus"] = "#{vmcpu}"
95   end
96   config.vm.provider "libvirt" do |lv|
97     lv.memory = "#{vmram}"
98     lv.cpus = "#{vmcpu}"
99   end
100   config.vm.provider "vmware_workstation" do |vws,override|
101     vws.vmx["memsize"] = "#{vmram}"
102     vws.vmx["numvcpus"] = "#{vmcpu}"
103   end
104 end