-
Notifications
You must be signed in to change notification settings - Fork 37
/
Vagrantfile
70 lines (57 loc) · 2.12 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrant Cassandra Project
# https://github.com/bcantoni/vagrant-cassandra
# Brian Cantoni
# This sample sets up 1 VM ('cassandra') with only Java installed.
# See the README for a walkthrough explaining Cassandra and DataStax installation.
# Adjustable settings
CFG_MEMSIZE = "3000" # max memory for each VM
CFG_TZ = "US/Pacific" # timezone, like US/Pacific, US/Eastern, UTC, Europe/Warsaw, etc.
CFG_IP = "10.211.54.10" # private IP address
# if local Debian proxy configured (DEB_CACHE_HOST), install and configure the proxy client
deb_cache_cmds = ""
if ENV['DEB_CACHE_HOST']
deb_cache_host = ENV['DEB_CACHE_HOST']
deb_cache_cmds = <<CACHE
apt-get install squid-deb-proxy-client -y
echo 'Acquire::http::Proxy "#{deb_cache_host}";' | sudo tee /etc/apt/apt.conf.d/30autoproxy
echo "Acquire::http::Proxy { debian.datastax.com DIRECT; };" | sudo tee -a /etc/apt/apt.conf.d/30autoproxy
echo "Acquire::http::Proxy { ppa.launchpad.net DIRECT; };" | sudo tee -a /etc/apt/apt.conf.d/30autoproxy
cat /etc/apt/apt.conf.d/30autoproxy
CACHE
end
# Provisioning script
node_script = <<SCRIPT
#!/bin/bash
# set timezone
echo "#{CFG_TZ}" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
#{deb_cache_cmds}
# install Java and a few base packages
add-apt-repository ppa:openjdk-r/ppa
apt-get update
apt-get install vim curl zip unzip git tree python-pip -y -q
# Java install - adjust if needed
# apt-get install openjdk-7-jdk -y -q
apt-get install openjdk-8-jdk -y -q
echo "Vagrant provisioning complete"
SCRIPT
# Configure VM server
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :cassandra do |x|
x.vm.box = "ubuntu/xenial64"
x.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = CFG_MEMSIZE
end
x.vm.provider :virtualbox do |v|
v.name = "cassandra"
v.customize ["modifyvm", :id, "--memory", CFG_MEMSIZE]
v.customize ["modifyvm", :id, "--cpus" , "2" ]
end
x.vm.network :private_network, ip: CFG_IP
x.vm.hostname = "cassandra"
x.vm.provision :shell, :inline => node_script
end
end