2014-01-19 14:34:01 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
2014-01-21 22:11:25 +00:00
|
|
|
def load_json(name)
|
|
|
|
path = File.join(File.dirname(__FILE__), "nodes", name)
|
|
|
|
JSON.load(File.open(path))
|
|
|
|
end
|
|
|
|
|
2014-01-19 14:34:01 +00:00
|
|
|
boxes = [
|
2014-01-21 22:11:25 +00:00
|
|
|
{ name: "node0.lctp", role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") },
|
|
|
|
{ name: "node1.lctp", role: :compute_node, mac: "5CA1AB1E0001", json: load_json("node1.json") }
|
2014-01-19 14:34:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
["vbguest", "berkshelf"].each do |plugin|
|
|
|
|
begin
|
|
|
|
require "vagrant-#{plugin}"
|
|
|
|
rescue LoadError
|
|
|
|
puts "#{plugin} plugin not installed!"
|
|
|
|
puts "run:"
|
|
|
|
puts "\tvagrant plugin install vagrant-#{plugin}"
|
|
|
|
exit(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
config.vm.box = "opscode_ubuntu-12.04_chef-11.4.4"
|
|
|
|
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.4.box"
|
|
|
|
|
|
|
|
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
|
|
|
|
# option to your ~/.vagrant.d/Vagrantfile file
|
|
|
|
config.berkshelf.enabled = true
|
|
|
|
|
|
|
|
chef_default = proc do |chef|
|
|
|
|
chef.cookbooks_path = "cookbooks"
|
|
|
|
chef.data_bags_path = "data_bags"
|
2014-01-21 22:11:25 +00:00
|
|
|
chef.roles_path = "roles"
|
2014-01-19 14:34:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
boxes.each do |box|
|
|
|
|
config.vm.define box[:name] do |node|
|
2014-01-21 22:11:25 +00:00
|
|
|
node.vm.provider :virtualbox do |vb|
|
|
|
|
vb.gui = true
|
|
|
|
# 1. adapter: NAT to allow vagrant setup the machine
|
|
|
|
# 2. adapter: for internal network between nodes
|
|
|
|
vb.customize ["modifyvm", :id,
|
|
|
|
"--nic1", "nat",
|
|
|
|
"--nictype1", "virtio",
|
|
|
|
"--nic2", "intnet",
|
|
|
|
"--nictype2", "virtio",
|
|
|
|
"--intnet2", "lctp",
|
|
|
|
"--macaddress2", box[:mac]]
|
2014-01-19 14:34:01 +00:00
|
|
|
end
|
|
|
|
|
2014-01-21 22:11:25 +00:00
|
|
|
node.vm.hostname = box[:name]
|
|
|
|
|
2014-01-19 14:34:01 +00:00
|
|
|
config.vm.provision :chef_solo do |chef|
|
|
|
|
chef_default.call(chef)
|
|
|
|
chef.add_role box[:role].to_s
|
2014-01-21 22:11:25 +00:00
|
|
|
chef.json = box[:json]
|
2014-01-19 14:34:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|