forked from ghaskins/riak-cluster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
75 lines (63 loc) · 2 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
71
72
73
74
75
# -*- mode: ruby -*-
# vi: set ft=ruby :
CENTOS = {
box: "opscode-centos-6.4",
url: "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box"
}
UBUNTU = {
box: "opscode-ubuntu-12.04",
url: "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
}
NODES = 3
OS = UBUNTU
BASE_IP = "33.33.33"
IP_INCREMENT = 10
Vagrant.configure("2") do |cluster|
# Ensure latest version of Chef is installed.
cluster.omnibus.chef_version = :latest
# Utilize the Berkshelf plugin to resolve cookbook dependencies.
cluster.berkshelf.enabled = true
(1..NODES).each do |index|
last_octet = index * IP_INCREMENT
cluster.vm.define "riak#{index}".to_sym do |config|
# Configure the VM and operating system.
config.vm.box = OS[:box]
config.vm.box_url = OS[:url]
config.vm.provider(:virtualbox) { |v| v.customize ["modifyvm", :id, "--memory", 1024] }
# Setup the network and additional file shares.
if index == 1
[ 8098, 8087, 8069 ].each do |port|
config.vm.network :forwarded_port, guest: port, host: port
end
end
config.vm.hostname = "riak#{index}"
config.vm.network :private_network, ip: "#{BASE_IP}.#{last_octet}"
config.vm.synced_folder "lib/", "/tmp/vagrant-chef-1/lib"
# Provision using Chef.
config.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
if config.vm.box =~ /ubuntu/
chef.add_recipe "apt"
else
chef.add_recipe "yum"
chef.add_recipe "yum::epel"
end
chef.add_role "base"
chef.add_role "riak"
chef.json = {
"riak" => {
"args" => {
"+S" => 1,
"-name" => "[email protected].#{last_octet}"
},
"config" => {
"riak_control" => {
"enabled" => (index == 1 ? true : false)
}
}
}
}
end
end
end
end