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-02-03 14:08:26 +00:00
|
|
|
#{ name: "puppet0.lctp", provision: :puppet, mac: "5CA1AB1E0F01"}, # uncomment to enable puppet
|
2014-02-03 14:06:12 +00:00
|
|
|
{ name: "node0.lctp", provision: :chef, role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") },
|
2014-03-02 23:00:40 +00:00
|
|
|
{ name: "node1.lctp", provision: :chef, role: :compute_node, mac: "5CA1AB1E0002", json: load_json("node1.json") },
|
|
|
|
#{ name: "node2.lctp", provision: :chef, role: :compute_node, mac: "5CA1AB1E0003", json: load_json("node2.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!"
|
2014-03-16 05:39:37 +00:00
|
|
|
puts "run:"
|
2014-01-19 14:34:01 +00:00
|
|
|
puts "\tvagrant plugin install vagrant-#{plugin}"
|
|
|
|
exit(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
2014-01-27 10:38:57 +00:00
|
|
|
config.vbguest.auto_update = true
|
|
|
|
config.vbguest.auto_reboot = true
|
|
|
|
|
2014-01-27 10:15:52 +00:00
|
|
|
config.vm.provision(:shell){ |shell| shell.path = "script/fix_stdin_error.sh" }
|
2014-01-19 14:34:01 +00:00
|
|
|
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|
|
2014-01-22 09:31:01 +00:00
|
|
|
# access via tty => user: vagrant, password: vagrant
|
2014-03-02 23:00:40 +00:00
|
|
|
#vb.gui = false
|
2014-01-22 09:31:01 +00:00
|
|
|
|
2014-01-21 22:11:25 +00:00
|
|
|
# 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-03-02 23:00:40 +00:00
|
|
|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
2014-01-21 22:11:25 +00:00
|
|
|
node.vm.hostname = box[:name]
|
2014-02-03 14:06:12 +00:00
|
|
|
|
|
|
|
if box[:provision] == :chef
|
|
|
|
node.vm.box = "opscode_ubuntu-12.04_chef-11.4.4"
|
|
|
|
node.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
|
|
|
|
node.berkshelf.enabled = true
|
|
|
|
|
|
|
|
# Update Chef in VM to specific version before running chef provisioner
|
|
|
|
node.vm.provision :shell do |shell|
|
|
|
|
shell.path = "script/upgrade_chef.sh"
|
|
|
|
# target version
|
|
|
|
shell.args = "11.8.2"
|
|
|
|
end
|
|
|
|
node.vm.provision :chef_solo do |chef|
|
2014-02-08 15:04:47 +00:00
|
|
|
# Verbose logging
|
|
|
|
#chef.arguments = '-l debug'
|
2014-02-03 14:06:12 +00:00
|
|
|
chef.cookbooks_path = "cookbooks"
|
|
|
|
chef.data_bags_path = "data_bags"
|
|
|
|
chef.roles_path = "roles"
|
|
|
|
chef.add_role box[:role].to_s
|
|
|
|
chef.json = box[:json]
|
|
|
|
end
|
|
|
|
elsif box[:provision] == :puppet
|
|
|
|
node.vm.box = "ubuntu-server-12042-x64-vbox4210"
|
|
|
|
node.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
|
|
|
|
|
|
|
|
node.vm.provision :puppet, options: ["--pluginsync"] do |puppet|
|
|
|
|
puppet.module_path = "modules"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
$stderr.puts "Unknown provisioning #{box[:provision]}"
|
2014-01-19 14:34:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|