# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" our_domain = "p4bsw.com" # Read VM config from JSON files bsw_config = (JSON.parse(File.read("cbd_test_config.json"))) class BSWError < Vagrant::Errors::VagrantError error_key "CBD Test Configuration error" end if !bsw_config.has_key?("oses") raise BSWError.new("Please define boxes in JSON file") end Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. # If true, then any SSH connections made will enable agent forwarding. # Default value: false config.ssh.forward_agent = true if Vagrant.has_plugin?("vagrant-hostmanager") config.hostmanager.enabled = true config.hostmanager.manage_host = true config.hostmanager.ignore_private_ip = false config.hostmanager.include_offline = true end bsw_config['oses'].each do |os| osname = os['osname'] os['nodes'].each do |node| #hostname = "#{osname}-#{node[':nodename']}" hostname = "#{node[':nodename']}" os_bootstrap = "bootstrap-#{osname}.sh" config.vm.define hostname.to_sym do |machine| if Vagrant.has_plugin?("vagrant-cachier") machine.cache.scope = :box end machine.vm.box = os['box'] machine.vm.box_url = os['box_url'] machine.vm.synced_folder "./shared", "/shared" # Set the root password to 'CBD4Me2Day' machine.vm.provision "shell", inline: "echo 'root:CBD4Me2Day' | sudo chpasswd" # Install various local things machine.vm.provision :shell, :path => os_bootstrap machine.vm.provision :shell, :path => "bootstrap-sdp-setup.sh" machine.vm.network :private_network, ip: node[':ip'] machine.vm.hostname = hostname + "." + our_domain machine.hostmanager.aliases = ["#{hostname}.localdomain", "#{hostname}"] end end end end