错误:未定义的方法';参考';对于nil:NilClass在节点vagrant-trusty64上

错误:未定义的方法';参考';对于nil:NilClass在节点vagrant-trusty64上,vagrant,puppet,Vagrant,Puppet,我在本地的流浪机器上的木偶清单有问题。每当我试图提供我的流浪者机器时,我都会收到以下输出,我似乎无法找到原因: Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan The following SSH command responded with a

我在本地的流浪机器上的木偶清单有问题。每当我试图提供我的流浪者机器时,我都会收到以下输出,我似乎无法找到原因:

Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan
Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

puppet apply --modulepath '/tmp/vagrant-puppet-1/modules-0:/etc/puppet/modules' --hiera_config=/tmp/vagrant-puppet-1/hiera.yaml --manifestdir /tmp/vagrant-puppet-1/manifests --detailed-exitcodes /tmp/vagrant-puppet-1/manifests/vagrant.pp || [ $? -eq 2 ]

Stdout from the command:



Stderr from the command:

stdin: is not a tty
Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan
Error: undefined method `ref' for nil:NilClass on node vagrant-trusty64.lan
关于从哪里开始调试有什么想法吗

流浪汉档案

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    # Use Phusion's Ubuntu 12.04 box with support for Docker
    config.vm.box = "phusion-open-ubuntu-14.04-amd64"
    config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
    # Set hostname
    config.vm.hostname = "vagrant-trusty64"

    # Configure the VirtualBox Provider
    config.vm.provider :virtualbox do |vb|
        # Give the VM 1GB of RAM
        # vb.customize ["modifyvm", :id, "--memory", "1024"]
    end

    # Provisioning with Puppet Standalone 
    config.vm.provision :puppet do |puppet|
        puppet.hiera_config_path = "conf/puppet/hiera.yaml"
        puppet.manifests_path = "manifests"
        puppet.manifest_file  = "vagrant.pp"
        puppet.module_path = "modules"
    end
end

首先,当试图调试这些问题时,正如他在对问题的评论中指出的,将Puppet的
--trace
参数添加到Vagrant使用的Puppet参数中:

Vagrant.configure("2") do |config|
    config.vm.provision :puppet do |puppet|
        # ...
        puppet.options = ["--debug", "--trace"]
    end
end
更好的解决方案是:

Vagrant.configure("2") do |config|
    config.vm.provision :puppet do |puppet|
        # ...
        if ENV.key?('PUPPET_OPTS')
            puppet.options = ENV['PUPPET_OPTS'].split(' ')
        end
    end
end
使用上述命令,只需在运行时定义
PUPPET\u OPTS
环境变量:

PUPPET_OPTS="--trace --debug" vagrant provision
这揭示了木偶作品中的普遍观点,即事情正在失败。我注释了一些内容,并将问题隔离到以下类:

class profiles::some::long::path {
    contain a, b, c
}

…其中
a
b
c
profiles::some::long::path
中的类。奇怪的是,不知怎的,这段代码在昨晚某个时候运行得很好

要开始这一步,您需要将
--trace
选项传递给Puppet。我不知道如何在Vagrant内部执行此操作。请向我们展示
Vagrant文件
@FelixFrank我知道如何执行此操作,这将是我的下一步。