Skip to content

Instantly share code, notes, and snippets.

@nohtyp
Last active January 11, 2016 02:53
Show Gist options
  • Select an option

  • Save nohtyp/8012603 to your computer and use it in GitHub Desktop.

Select an option

Save nohtyp/8012603 to your computer and use it in GitHub Desktop.
My vagrant file...better example of how easy it is to add new servers
domain = 'familyguy.com'
VAGRANTFILE_API_VERSION = "2"
VAGRANT_BOX_URL = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"
VAGRANT_TMP_NAME = "centos-min"
VBGUI = false
nodes = [
{ :hostname => 'peter', :ip => '192.168.2.10', :box => 'centos-min' },
{ :hostname => 'lois', :ip => '192.168.2.11', :box => 'centos-min' },
{ :hostname => 'stewie', :ip => '192.168.2.12', :box => 'centos-min'},
{ :hostname => 'brian', :ip => '192.168.2.13', :box => 'centos-min'},
]
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#If template box is not installed download and install and name centos-min
config.vm.box_url = VAGRANT_BOX_URL
config.vm.box = VAGRANT_TMP_NAME
nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.box = node[:box]
node_config.vm.host_name = node[:hostname] + '.' + domain
node_config.vm.network :private_network, ip: node[:ip]
#Set memory default to 480MB if not defined in nodes array
memory = node[:ram] ? node[:ram] : 480;
node_config.vm.provider :virtualbox do |vb|
#Set VBGUI to true if you want to troubleshoot the bootup of the VM's
vb.gui = VBGUI
#Modify the vm's config..most important (--name) this changes the name in the virtualbox interface
vb.customize ['modifyvm', :id, '--name', node[:hostname], '--memory', memory.to_s ]
end
end
end
#Sets up the puppet provisioner so it can be used to provisioin the server.
#config.vm.provision :puppet do |puppet|
# puppet.manifests_path = 'puppet/manifests'
# puppet.manifest_file = 'site.pp'
# puppet.module_path = 'puppet/modules'
#end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment