Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Last active February 2, 2016 15:45
Show Gist options
  • Save binarytemple/36f7f5796873fbf98494 to your computer and use it in GitHub Desktop.
Save binarytemple/36f7f5796873fbf98494 to your computer and use it in GitHub Desktop.
Vagrantfile which for each file in the directory configs creates and provisions a corresponding host
#########################################################
# Usage:
# * Create a sub-directory 'configs'
# * Within that directory:
# ** Create one shell script per-host
# ** Each script must have a '.sh' suffix
# ** The script prefix will correspond with the hostname
#########################################################
Vagrant.configure(2) do |config|
config.vm.box = "bento/centos-6.7"
Dir.foreach('fetched.configs') do |item|
next if item == '.' or item == '..'
hostname = item.sub(/\.sh$/,"")
config.vm.define hostname do |config|
config.vm.hostname = hostname
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = 512
v.vmx["numvcpus"] = 1
end
config.vm.provision "shell", path:"./fetched.configs/#{item}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment