Created
December 16, 2015 14:03
-
-
Save danielalvarenga/12f56f8e27ffb456c5da to your computer and use it in GitHub Desktop.
Vagrant with shell script provision customizable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network :forwarded_port, guest: 3000, host: 3000 | |
config.vm.network :private_network, ip: "10.11.12.13" | |
config.ssh.forward_agent = true | |
config.vm.synced_folder ".", "/vagrant" | |
config.vm.boot_timeout = 120 | |
config.vm.provider "virtualbox" do |v| | |
host = RbConfig::CONFIG['host_os'] | |
if host =~ /darwin/ | |
cpus = `sysctl -n hw.ncpu`.to_i | |
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 2 | |
else | |
cpus = `nproc`.to_i | |
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 2 | |
end | |
v.customize ["modifyvm", :id, "--memory", mem] | |
v.customize ["modifyvm", :id, "--cpus", cpus] | |
end | |
# Verify script configuration for customize instalation | |
# Shell Script: https://gist.github.com/danielalvarenga/c23449bd88779532e13d | |
config.vm.provision "shell", path: "script-install-all-ubuntu14.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment