Skip to content

Instantly share code, notes, and snippets.

@lu-chi
Forked from scottslowe/yaml-vagrantfile
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save lu-chi/68130b27c2f21425198f to your computer and use it in GitHub Desktop.

Select an option

Save lu-chi/68130b27c2f21425198f to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# # vi: set ft=ruby :
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
# Require YAML module
require 'yaml'
# Read YAML file with box details
servers = YAML.load_file('servers.yaml')
# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file
servers.each do |servers|
config.vm.define servers["name"] do |srv|
srv.vm.box = servers["box"]
srv.vm.network "private_network", ip: servers["ip"]
srv.vm.provider :virtualbox do |vb|
vb.name = servers["name"]
vb.memory = servers["ram"]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment