Skip to content

Instantly share code, notes, and snippets.

@devynspencer
Created December 10, 2015 01:24
Show Gist options
  • Select an option

  • Save devynspencer/1f33a5fa5455f15bb09e to your computer and use it in GitHub Desktop.

Select an option

Save devynspencer/1f33a5fa5455f15bb09e to your computer and use it in GitHub Desktop.
Global defaults for Chef development using Vagrant. ~/.vagrant.d/Vagrantfile
# global defaults file
def host_hardware_info
hardware = {}
operating_system = RbConfig::CONFIG['host_os']
case operating_system
when /darwin/
hardware[:cpu_cores] = `sysctl -n hw.cpus`.to_i
hardware[:memory] = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4 # MB
when /linux/
hardware[:cpu_cores] = `nproc`.to_i
hardware[:memory] = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/kB//'`.to_i / 1024 / 4 # MB
else
hardware[:cpu_cores] = 1
hardware[:memory] = 2048
end
hardware
end
Vagrant.configure("2") do |config|
config.vm.box = 'bento/centos-7.1'
config.vm.box_url = ''
config.vm.box_check_update = false
config.vm.post_up_message = 'Include helpful instructions for box users here.'
config.vm.provider "virtualbox" do |vb|
hardware = host_hardware_info
vb.cpus = hardware[:cpu_cores]
vb.memory = hardware[:memory]
end
config.vm.network :private_network, type: :dhcp
if Vagrant.has_plugin? 'vagrant-cachier'
config.cache.scope = :box
config.cache.synced_folder_opts = { type: :rsync }
end
if Vagrant.has_plugin? 'vagrant-omnibus'
config.omnibus.chef_version = :latest
config.omnibus.cache_packages = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment