在为EC2配置时,我只想要' app' VM。在本地配置时,我想要' app'并且' pg'。我在编写可以满足这两种情况的单个Vagrant文件时遇到了麻烦。
我想通过使用提供程序作为一种方法来调用它:
vagrant up --provider=aws
VS
vagrant up --provider=virtualbox
AWS会生成app。 Virtualbox会产生app和pg。
我正在使用vagrant 1.7.2
我有类似下面的Vagrantfile:
...
Vagrant.configure(2) do |config|
...
config.vm.define "app" do |app|
# setup app here
...
config.vm.provider :virtualbox do |vbox, override|
# setup virtualbox for app vm here
...
end
...
config.vm.provider :aws do |aws, override|
# setup aws for app vm here
...
end
end
...
config.vm.define "pg" do |pg|
# setup postgres here
...
end
...
end
编辑:澄清调用。
答案 0 :(得分:1)
It looks good, you will do vagrant up app --provider=aws
for AWS where only app will be started (and provisioned if needed) or vagrant up
if you want local and both VM will be created
However Vagrant does support running Vagrantfile with multiple number of providers at the same time, one thing you can do is to create VM/environment for each provider and then rename the .vagrant
directory after it has been created.