blob: be0824dbd55aec3ac2d3ca8b12a1fac852ae535f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
disable_gui = ENV['VESPA_VAGRANT_DISABLE_GUI']
def get_mandatory_env_value(name)
opt = ENV[name]
if opt.nil? or opt.empty?
raise Vagrant::Errors::VagrantError.new, "Environment variable #{name} must be set to a valid value before running vagrant"
end
return opt
end
def get_env_value(name, fallback)
opt = ENV[name]
if opt.nil? or opt.empty?
return fallback
end
return opt
end
vm_box = get_mandatory_env_value('VESPA_VAGRANT_VM_BOX')
vm_memory = get_env_value('VESPA_VAGRANT_VM_MEMORY', "8192")
vm_cpus = get_env_value('VESPA_VAGRANT_VM_CPUS', 4)
unless disable_gui
vm_box_url = get_mandatory_env_value('VESPA_VAGRANT_VM_BOX_URL')
end
# For a complete reference, please see the online documentation at https://docs.vagrantup.com.
Vagrant.configure("2") do |config|
config.vm.box = vm_box
config.vm.box_url = vm_box_url unless disable_gui
config.ssh.forward_agent = true
config.vm.synced_folder "../dist", "/vagrant/dist"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true unless disable_gui
vb.name = "vespa-dev"
vb.memory = vm_memory
vb.cpus = vm_cpus
end
# Install required and nice-to-have packages
config.vm.provision "shell", inline: <<-SHELL
yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/g/vespa/vespa/repo/epel-7/group_vespa-vespa-epel-7.repo
yum -y install epel-release
yum -y install centos-release-scl
yum -y install yum-utils
yum -y install git \
ccache \
maven \
rpm-build \
valgrind \
sudo \
firefox \
vim \
emacs
sed -e '/^BuildRequires:/d' -e 's/^Requires:/BuildRequires:/' /vagrant/dist/vespa.spec > /tmp/vesparun.spec
yum-builddep -y /vagrant/dist/vespa.spec /tmp/vesparun.spec
rm /tmp/vesparun.spec
echo -e "* soft nproc 409600\n* hard nproc 409600" > /etc/security/limits.d/99-nproc.conf
echo -e "* soft nofile 262144\n* hard nofile 262144" > /etc/security/limits.d/99-nofile.conf
unless disable_gui
echo -e "fs.inotify.max_user_watches = 524288" > /etc/sysctl.d/clion.conf
wget -q -O - https://download.jetbrains.com/cpp/CLion-2018.1.6.tar.gz | tar -C /opt -zx
ln -sf /opt/clion-2018.1.6/bin/clion.sh /usr/bin/clion
end
yum update -y
hostname localhost
SHELL
# Add settings for Vespa and dev tools as the default user, usually 'vagrant' (privileged: false)
# NOTE: adding these settings to .bashrc would break vagrant suspend/resume/provision
# due to env vars modified by /opt/rh/devtoolset-8/enable.
config.vm.provision "shell", privileged: false, inline: <<-SCRIPT
grep -l VESPA_HOME ~/.bash_profile >/dev/null || (\
printf "%s\n" \
'export VESPA_HOME=$HOME/vespa' \
'export PATH=$PATH:$VESPA_HOME/bin' \
'source /opt/rh/rh-maven35/enable' \
'source /opt/rh/devtoolset-8/enable' \
>> ~/.bash_profile )
SCRIPT
end
|