Vagrant Multiple Box Config

Vagrant Multiple Box Config

随着不同框架的不同技术栈,导致一个Vagrant Box显然无法适应所有情况.所以多Box设置势在必行,Google后整理结果如下:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.define "magento" do |web|
        web.vm.box = "ubuntu/xenial64"
        web.vm.hostname = 'magento'

        web.vm.network "private_network", ip: "192.168.33.11"

        web.vm.provider :virtualbox do |v|
            v.customize ["modifyvm", :id, "--memory", "2048"]
            v.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
            v.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
        end
    end


    config.vm.define "php" do |php|
        php.vm.box = "ubuntu/trusty64"
        php.vm.hostname = 'php'

        php.vm.network :private_network, ip: "192.168.33.10"

        php.vm.provider :virtualbox do |v|
            v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
            v.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
            v. memory = 1024 
        end
    end
    
end

感谢Scott Keck-Warren的文章,简单粗暴直接的解决问题.

Reference

  1. Multiple Vagrant VMs in One Vagrantfile

  2. Customizations Arg

标签: none

添加新评论