首先,这是我得到的错误:
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.
厨师服务器 URL 似乎已填充,并且验证密钥路径有效。
我有 3 个 Vagrantfiles 生效,我正在使用文档来尝试正确地获取订单。
当我将所有内容都粘贴在项目目录中的一个 Vagrantfile 中时,这可以正常工作,但是我想设置默认值,而不必复制粘贴所有内容。
1)随盒子打包的Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :vsphere do |vsphere|
vsphere.host = 'vsphereserver.example.com'
vsphere.compute_resource_name = 'TestDev'
vsphere.user = 'vagrantadmin'
vsphere.password = 'password'
vsphere.insecure = true
end
config.ssh.username = 'auto'
config.ssh.private_key_path = '~/.vagrant.d/id_rsa'
end
2) 我的主目录 (~/.vagrant.d) 中的 Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = 'vsphere'
config.vm.provider :vsphere do |vsphere|
vsphere.template_name = 'vagrantchefnode'
end
config.vm.provision "chef_client" do |chef|
chef.add_role "base"
chef.provisioning_path = "/etc/chef"
chef.chef_server_url = "https://chefserver.example.com"
chef.validation_key_path = "/home/user/.vagrant.d/chef/validation.pem"
chef.client_key_path = "/etc/chef/client.pem"
chef.validation_client_name = "chef-validator"
chef.custom_config_path = "/home/user/.vagrant.d/Vagrantfile.chef"
chef.delete_node = true
chef.delete_client = true
end
end
3) 项目目录中的 Vagrantfile (~/.vagrant.d/boxes/chefnode1):
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :vsphere do |vsphere|
# vsphere.template_name = 'chefnode'
vsphere.customization_spec_name = 'chefnode1'
vsphere.name = 'chefnode1'
end
config.vm.provision "chef_client" do |chef|
chef.node_name = "chefnode1"
chef.add_role "test"
end
end
它是否以某种方式覆盖了整个 chef_client 配置?如果是这样,我如何让它坚持并合并它应该的方式?
更新:
我有一些与 Tejay 的答案和这个 doc一起使用的东西,但它需要翻译成不同的语法,我不知道如何获得add_role
翻译之类的方法。这是我所拥有的:
2)
config.vm.provision "chef_client",
id: "chef",
provisioning_path: "/etc/chef",
chef_server_url: "https://chefserver.example.com",
validation_key_path: "/home/user/.vagrant.d/chef/validation.pem",
client_key_path: "/etc/chef/client.pem",
validation_client_name: "chef-validator",
custom_config_path: "/home/user/.vagrant.d/Vagrantfile.chef",
delete_node: true,
delete_client: true
3)
config.vm.provision "chef_client",
id: "chef",
node_name: "chefnode1"
所以这会启动机器,但我无法指定 run_list。