From b59162c64c41ca07e82c68767805c9e5967eb68f Mon Sep 17 00:00:00 2001 From: Ilya Rogov Date: Thu, 24 Jul 2014 18:26:03 +0400 Subject: [PATCH] added Environment variables --- README.md | 17 +++++++++++++++++ Vagrantfile | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 732c1a24..4d77bdec 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,23 @@ Go to the repository folder and launch the box $ cd [repo] $ vagrant up +Environment variables +------------------------- + +### Default values + +```bash +VM_MEMORY=512 +VM_CORES=1 +VM_ARCH=32 +``` + +### Examples uses + +```bash +VM_MEMORY=1024 VM_CORES=2 VM_ARCH=64 vagrant up +``` + What's inside: -------------- diff --git a/Vagrantfile b/Vagrantfile index 4cfd21a5..cb4748a8 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,17 +1,21 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +MEMORY = ENV['VM_MEMORY'] || '512' +CORES = ENV['VM_CORES'] || '1' +ARCH = ENV['VM_ARCH'] || '32' + Vagrant.configure("2") do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "precise32" + config.vm.box = "precise#{ARCH}" # The url from where the 'config.vm.box' box will be fetched if it # doesn't already exist on the user's system. - config.vm.box_url = "http://files.vagrantup.com/precise32.box" + config.vm.box_url = "http://files.vagrantup.com/precise#{ARCH}.box" # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. @@ -31,7 +35,12 @@ Vagrant.configure("2") do |config| # These expose provider-specific options. config.vm.provider :virtualbox do |vb| # Use VBoxManage to customize the VM. For example to change memory: - vb.customize ["modifyvm", :id, "--memory", "512"] + vb.customize ["modifyvm", :id, "--memory", MEMORY.to_i] + vb.customize ["modifyvm", :id, "--cpus", CORES.to_i] + + if CORES.to_i > 1 + vb.customize ["modifyvm", :id, "--ioapic", "on"] + end end # Enable provisioning with chef solo, specifying a cookbooks path, roles