# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" def load_json(name) path = File.join(File.dirname(__FILE__), "nodes", name) JSON.load(File.open(path)) end boxes = [ { name: "node0.lctp", role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") }, { name: "node1.lctp", role: :compute_node, mac: "5CA1AB1E0002", json: load_json("node1.json") } ] ["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 config.vbguest.auto_update = true config.vbguest.auto_reboot = true chef_default = proc do |chef| chef.cookbooks_path = "cookbooks" chef.data_bags_path = "data_bags" chef.roles_path = "roles" end # Update Chef in VM to specific version before running chef provisioner config.vm.provision :shell do |shell| shell.path = "script/upgrade_chef.sh" # target version shell.args = "11.8.2" end config.vm.provision(:shell){ |shell| shell.path = "script/fix_stdin_error.sh" } boxes.each do |box| config.vm.define box[:name] do |node| node.vm.provider :virtualbox do |vb| # access via tty => user: vagrant, password: vagrant #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]] end node.vm.hostname = box[:name] node.vm.provision :chef_solo do |chef| chef_default.call(chef) chef.add_role box[:role].to_s chef.json = box[:json] end end end end