无法评估:无法从环境生产源puppet:/// modules / toolchain检索信息

问题描述

我试图编写一个简单的资源,将可怕的内容从人偶主控复制到人偶代理。

file { "/usr/local/scaligent/" :
    ensure => 'directory',source => "puppet:///modules/toolchain",recurse => 'true',#owner => 'root',#group => 'root',#mode => '0755',}

在puppet master中,源是/ etc / puppetlabs / code / environments / production / modules / files / toolchain /,在puppet代理中,目标是/ usr / local / scaligent/。

在人偶代理中获得以下错误

[~]$ sudo puppet agent -tv --noop
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Applying configuration version '1600365429'
Error: /Stage[main]/Main/File[/usr/local/scaligent/]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/toolchain
Notice: Applied catalog in 0.04 seconds
[ ~]$

解决方法

根据人偶resource type referencepuppet: URI的形式为

puppet:///modules/<MODULE NAME>/<FILE PATH>

它是指模块中文件或目录中的内容,Puppet将在该文件或目录的模块files目录中查找该文件或目录的内容。文件系统路径类似于/etc/puppetlabs/code/environments/production/modules/<MODULE NAME>/files/toolchain

您尝试使用的URI puppet:///modules/toolchain格式不正确,并且您尝试引用的路径不在任何模块的files/目录中。

将“ toolchain”目录放在包含资源声明的模块文件中是常规的做法,尽管不是必需的。但是然后,将File声明放在您尚未完成的类,模块中也是惯例。在大约零的情况下,就像您似乎已经做过的那样,最好在顶部范围内声明该资源。