我想知道在使用 Vagrant 创建多机环境时是否有办法为配置程序指定默认值?
我试图做类似以下的事情:
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
但是每个 VM 块似乎都没有选择任何主要的配置块设置。我收到此错误:
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.
可以通过其他方法吗?