-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
56 lines (42 loc) · 1.41 KB
/
Vagrantfile
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
$bootstrap = <<-SCRIPT
echo "install dependancies"
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk nodejs npm
echo "install cassandra"
wget https://mirror.netcologne.de/apache.org/cassandra/3.11.6/apache-cassandra-3.11.6-bin.tar.gz
tar -xzvf apache-cassandra-3.11.6-bin.tar.gz
mv apache-cassandra-3.11.6 /opt/cassandra
rm apache-cassandra-3.11.6-bin.tar.gz
# add rights to vagrant user for /opt folder
chown -R vagrant:vagrant /opt
# change default directory if it exists
[ -f /etc/profile ] || touch /etc/profile
echo '
[ ! -d /vagrant ] || cd /vagrant' | tee -a /etc/profile
SCRIPT
$startup = <<-SCRIPT
# start cassandra
# http://cassandra.apache.org/doc/latest/getting_started/installing.html
cd /opt/cassandra
./bin/cassandra -R
# start nodejs
cd /vagrant/server
npm install
# wait until cassandra is ready
while ! /opt/cassandra/bin/cqlsh -e 'describe cluster' ; do
sleep 1
done
node index.js &
echo 'express server started'
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "8192"]
vb.customize ["modifyvm", :id, "--cpus", "4"]
vb.customize ["modifyvm", :id, "--uartmode1", "disconnected" ]
end
config.vm.network "private_network", ip: "192.168.18.101"
config.vm.provision "shell", inline: $bootstrap
config.vm.provision "shell", inline: $startup, run: 'always'
end