blob: 7ae899c94f99cebda2152ac09933b54c7d2303a1 [file] [log] [blame]
Zsolt Haraszti3d163532016-09-08 15:57:32 -07001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
Sergio Slobodrianbf77c862017-06-08 13:24:27 -04004require 'yaml'
5
6settings = YAML.load_file 'settings.vagrant.yaml'
7
Zsolt Haraszti3d163532016-09-08 15:57:32 -07008Vagrant.configure(2) do |config|
9
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040010 if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
11 puts("Configuring for windows")
alshabibeef9b132017-02-02 17:46:51 -080012 config.vm.synced_folder "../..", "/cord", mount_options: ["dmode=700,fmode=600"]
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040013 Box = "ubuntu/xenial64"
14 Provider = "virtualbox"
15 elsif RUBY_PLATFORM =~ /linux/
16 puts("Configuring for linux")
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040017 if settings['vProvider'] == "virtualbox"
18 puts("Using the virtualbox configuration");
19 config.vm.synced_folder "../..", "/cord"
20 Box = "ubuntu/xenial64"
21 Provider = "virtualbox"
22 else
23 puts("Using the QEMU/KVM configuration");
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040024 Box = "ubuntu1604"
25 Provider = "libvirt"
Sergio Slobodrian36e16552017-06-19 11:00:45 -040026 if settings['testMode'] == "true" or settings['installMode'] == "true"
Sergio Slobodrian7c483622017-06-13 15:51:34 -040027 config.vm.synced_folder ".", "/vagrant", disabled: true
Sergio Slobodrian36e16552017-06-19 11:00:45 -040028 config.vm.synced_folder "../..", "/cord", type: "rsync", rsync__exclude: [".git", "venv-linux", "install/volthaInstaller", "install/volthaInstaller-2"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"]
Sergio Slobodrian7c483622017-06-13 15:51:34 -040029 else
30 config.vm.synced_folder "../..", "/cord", type: "nfs"
31 end
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040032 end
Zsolt Haraszti3d163532016-09-08 15:57:32 -070033 else
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040034 puts("Configuring for other")
alshabibeef9b132017-02-02 17:46:51 -080035 config.vm.synced_folder "../..", "/cord"
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040036 Box = "ubuntu/xenial64"
37 Provider = "virtualbox"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070038 end
39
Sergio Slobodrian7c483622017-06-13 15:51:34 -040040 config.vm.define "#{settings['server_name']}" do |d|
Zsolt Haraszti3d163532016-09-08 15:57:32 -070041 d.ssh.forward_agent = true
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040042 d.vm.box = Box
khenaidoo3a7a4e52017-07-14 15:31:46 -040043 if Box == "ubuntu/xenial64"
44 d.vm.box_version = "20170207.0.0"
45 end
Sergio Slobodrian7c483622017-06-13 15:51:34 -040046 d.vm.hostname = "#{settings['server_name']}"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070047 d.vm.network "private_network", ip: "10.100.198.220"
48 d.vm.provision :shell, path: "ansible/scripts/bootstrap_ansible.sh"
alshabibeef9b132017-02-02 17:46:51 -080049 d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/incubator/voltha/ansible/voltha.yml -c local"
50 d.vm.provision :shell, inline: "cd /cord/incubator/voltha && source env.sh && make install-protoc && chmod 777 /tmp/fluentd"
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040051 d.vm.provider Provider do |v|
Zsolt Haraszti9b485fb2016-12-26 23:11:15 -080052 v.memory = 6144
Sergio Slobodriancab0a392017-07-13 08:42:10 -040053 v.cpus = 4
Zsolt Haraszti3d163532016-09-08 15:57:32 -070054 end
55 end
56
57 if Vagrant.has_plugin?("vagrant-cachier")
58 config.cache.scope = :box
59 end
60
61end