无法从生产环境源检索信息

11

我正在一个vagrant项目中使用puppet作为我的配置管理器。我尝试添加一个自定义bash_profile的模块。

puppet的module_path已设置为:

 puppet.module_path = "puppet/modules"

我的bash_profile模块的类看起来像这样:

class bash_profile
{
    file
    {
        "/home/vagrant/bash_profile":
            ensure => present,
            source => "puppet:///modules/bash_profile/files/bash_profile"
    }
}

这是我的 Puppet 结构的文件结构:

puppet
| manifests
| | phpbase.pp // my main manifest file that has includes for modules
| modules
| | bash_profile
| | | files
| | | | bash_profile // the actual bash_profile file I want to ensure is present on my VM
| | | manifests
| | | | init.pp // the init file included for the bash_profile class

当我运行Vagrant的配置时,遇到了以下错误:

错误:/Stage[main]/Bash_profile/File[/home/vagrant/bash_profile]无法评估:无法从环境生产源“puppet:///modules/bash_profile/files/bash_profile”检索信息,位于/tmp/vagrant-puppet-1/modules-0/bash_profile/manifests/init.pp:8

我不确定为什么无法检索信息。路径似乎是正确的。有人能看出我错过了什么吗?


@timbooo,只是好奇,你为什么编辑了标题?我这样前缀我的问题,这样以后查找起来更容易。 - Chris Schmitz
不必在标题中加入标签,参见此链接。您也可以使用标签以主题相关的方式浏览您的问题。 - dertkw
明白了,感谢提供链接和澄清。 - Chris Schmitz
3个回答

26

是的,你不应该在URL中包含文字 files/。相反,它应该只是

puppet:///modules/bash_profile/bash_profile

3
我刚刚阅读了同样的文档,也没注意到同一个细节。我花费了四个小时才搞清楚那个URL!我还尝试使用文件URI。我的同事说,在源属性中,你需要去掉 "file:" 这个部分。我不太确定,但他这么做可以奏效。 - Paul Chernoch
5
哎呀,那绝对与我对路径的期望背道而驰。 - Ehtesh Choudhury

1
如果您的模块名称无效,使用recurse => true也会出现此错误。例如,如果您有以下模块结构:

modules ├── my-example │ └── files │ └── example │ └── test.txt

和这个资源:
file { "/tmp/example":
  ensure => directory,
  recurse => true,
  source => "puppet:///modules/my-example/example",
}

您将收到以下错误:

==> default: 信息:无法在生产环境中找到文件“my-example/example”的文件系统信息 ==> default: 错误:/Stage[main]/Main/Node[default]/File[/tmp/example]:无法评估:无法从环境生产源(puppet:///my-example/example)检索信息

解决方法是重命名模块,例如将其命名为my_example模块名称的规则已记录,但很容易被忽略。


0

需要注意的事项

  1. Puppet URI格式为 puppet:///modules/name_of_module/filename
  2. 文件服务器目录应该存在于模块目录中

这个视频是一个逐步指南,用于解决错误。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接