我想知道在使用Vagrant创建多机环境时是否有一种指定provisioners默认值的方法?
我试图做如下操作:
可以通过另一种方法实现吗?
我试图做如下操作:
Vagrant.configure("2") do |config|
config.vm.box = "andyshinn/ubuntu-precise64"
config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/myorg"
chef.validation_key_path = "~/.chef/myorg-validator.pem"
chef.delete_node = true
chef.delete_client = true
chef.validation_client_name = "myorg-validator"
end
config.vm.define :app do |app|
app.vm.network "private_network", ip: "172.16.64.61"
app.vm.host_name = "vagrant-app-#{ENV['USER']}"
app.vm.provision :chef_client do |chef|
chef.add_recipe "myrecipe1"
chef.add_recipe "myrecipe2"
chef.add_recipe "sudo"
end
end
config.vm.define :web do |web|
web.vm.network "private_network", ip: "172.16.64.62"
web.vm.host_name = "vagrant-web-#{ENV['USER']}"
web.vm.provision :chef_client do |chef|
chef.add_recipe "myrecipe3"
chef.add_recipe "myrecipe4"
chef.add_recipe "sudo"
end
end
end
但是每个虚拟机块似乎都没有获取到任何主配置块的设置。我遇到了这个错误:
There are errors in the configuration of this machine. Please fix
the following errors and try again:
chef client provisioner:
* Chef server URL must be populated.
* Validation key path must be valid path to your chef server validation key.
可以通过另一种方法实现吗?
.Vagrantfile
通常描述一个自包含的虚拟机。当你谈论multi-machine
环境时,这似乎有些可疑,因为答案是多个.Vagrantfile
。你是否认为你正在尝试做一些Vagrant并不打算做的事情? - nsfyn55