Multiple Provider Vagrant Files

With the latest Vagrant out, you can start to do some cool things, like use different back ends. However, what if some of your team uses Fusion while others use vBox, and then for production you need to deploy to some flavor of Cloud?

For the most part, your vagrant file will be able to stay the same, however, there are some gotchas:

Changing Memory

Here’s how you’d change the memory setting for each Fusion, vBox, and Rackspace Clouds:

Fusion

box.vm.provider :vmware_fusion do |v|
    v.vmx[“memsize”] = 1024
end

vBox

box.vm.provider :virtualbox do |vbox|
    vbox.customize [“modifyvm”, :id, “–memory”, 1024]
end

Rackspace / OpenStack

Note: This will also be similar for AWS and the OpenStack provider.

box.vm.provider :rackspace do |rs|
    rs.username = “yourName”
    rs.api_key  = “zomgkey”
    rs.flavor   = /1GB/
    rs.image    = /Ubuntu 12.04/
end

Changing CPU Settings

For this one I’ll show the vBox and Fusion methods as depending on the cloud provider, the Flavor you select will also determine the number of CPU’s in the given instance.

Fusion

box.vm.provider :vmware_fusion do |v|
    v.vmx[“numvcpus”] = 2
end

vBox

box.vm.provider :virtualbox do |vbox|
    vbox.customize [“modifyvm”, :id, “–cpus”, “2”]
end

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.