这是一个非常奇怪的海森虫。有时,当我打电话时vagrant up
,我会得到这样的信息:
Bringing machine 'default' up with 'vsphere' provider...
==> default: Calling vSphere CloneVM with the following settings:
==> default: -- Template VM: COLUMBIA/vm/DirectChannel/vagrantchefnode
==> default: -- Target VM: COLUMBIA/vm/DirectChannel/dirchantsrv1
==> default: Waiting for SSH to become available...
undefined method `[]' for nil:NilClass
(我完全忘记了最后一行的样子,我正在尝试从使用 --debug 标记运行的日志中重新创建它。)
在我设置了我的 Vagrantfiles 之后,它第一次就这样做了,然后之后vagrant destroy
,就毫无问题地继续过去了。有一次我每次都这样做,所以我将调试输出发送到日志文件。然后我编辑了 Vagrantfile,它停止了。然后我将 Vagrant 文件编辑回原来的样子,但它仍然没有再次发生。我需要知道是什么原因造成的,这样我才能确保它不会再次发生。
以下是日志文件中包含“nil”的行:
DEBUG command: -- options: {:provider=>nil}
INFO batch_action: Starting action: #<Vagrant::Machine:0x000000018bb658> up {:destroy_on_error=>true, :parallel=>true, :provision_ignore_sentinel=>false, :provision_types=>nil}
INFO machine: New machine ID: nil
ERROR warden: Error occurred: undefined method `[]' for nil:NilClass
ERROR warden: Error occurred: undefined method `[]' for nil:NilClass
ERROR warden: Error occurred: undefined method `[]' for nil:NilClass
ERROR warden: Error occurred: undefined method `[]' for nil:NilClass
ERROR vagrant: #<VagrantPlugins::VSphere::Errors::VSphereError: undefined method `[]' for nil:NilClass>
ERROR vagrant: undefined method `[]' for nil:NilClass
INFO interface: error: undefined method `[]' for nil:NilClass
undefined method `[]' for nil:NilClass
INFO interface: Machine: error-exit ["VagrantPlugins::VSphere::Errors::VSphereError", "undefined method `[]' for nil:NilClass"]
这是 Vagrantfiles:
1)随盒子打包的Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :vsphere do |vsphere|
vsphere.host = 'vsphereserver.myorg.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", id: "chef" do |chef|
chef.provisioning_path = "/etc/chef"
chef.chef_server_url = "https://chefserver.myorg.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
chef.add_role "base"
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 = 'test2'
vsphere.name = 'test2'
end
config.vm.provision "chef_client", id: "chef" do |chef|
chef.node_name = "test2"
chef.add_role "dev"
end
end
我觉得 VMware 方面出了点问题,但我没有 VMware 主机的完全访问权限。有任何想法吗?