Skip to content

Commit

Permalink
Merge pull request #487 from roots/vagrant-performance-one-cpu
Browse files Browse the repository at this point in the history
Fixes #410 - Default to 1 CPU in Vagrant
  • Loading branch information
swalkinshaw committed Feb 15, 2016
2 parents 3354a00 + 7228fdb commit 9045879
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
### HEAD
* Fixes #410 - Default to 1 CPU in Vagrant ([#487](https://github.com/roots/trellis/pull/487))

### 0.9.5: February 10th, 2016
* Fix Nginx includes for Ansible 2.0 ([#473](https://github.com/roots/trellis/pull/473))
* Use `ondrej/php` PPA since `ondrej/php-7.0` is deprecated ([#479](https://github.com/roots/trellis/pull/479))
Expand Down
37 changes: 8 additions & 29 deletions Vagrantfile
Expand Up @@ -85,57 +85,36 @@ Vagrant.configure('2') do |config|
end
end

# Give VM access to all cpu cores on the host
cpus = case RbConfig::CONFIG['host_os']
when ENV['NUMBER_OF_PROCESSORS'] then ENV['NUMBER_OF_PROCESSORS'].to_i
when /darwin/ then `sysctl -n hw.ncpu`.to_i
when /linux/ then `nproc`.to_i
else 2
end

# Give VM more memory
memory = 1024
cpus = 1
memory = 1024 # in MB

# Virtualbox settings
config.vm.provider 'virtualbox' do |vb|
# Customize VM settings
vb.customize ['modifyvm', :id, '--memory', memory]
vb.name = config.vm.hostname
vb.customize ['modifyvm', :id, '--cpus', cpus]
vb.customize ['modifyvm', :id, '--memory', memory]

# Fix for slow external network connections
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']

# Set VM name
vb.name = config.vm.hostname
end

# VMware Workstation/Fusion settings
['vmware_fusion', 'vmware_workstation'].each do |provider|
config.vm.provider provider do |vmw, override|
# Override provider box
override.vm.box = 'puppetlabs/ubuntu-14.04-64-nocm'

# Customize VM settings
vmw.vmx['memsize'] = memory
vmw.vmx['numvcpus'] = cpus

# Set VM name
vmw.name = config.vm.hostname
vmw.vmx['numvcpus'] = cpus
vmw.vmx['memsize'] = memory
end
end

# Parallels settings
config.vm.provider 'parallels' do |prl, override|
# Override provider box
override.vm.box = 'parallels/ubuntu-14.04'

# Customize VM settings
prl.memory = memory
prl.cpus = cpus

# Set VM name
prl.name = config.vm.hostname
prl.cpus = cpus
prl.memory = memory
end

end
Expand Down

0 comments on commit 9045879

Please sign in to comment.