无法从环境生产源文件中检索信息:///
Could not retrieve information from environment production source(s) file:///
我有一个人偶 class 定义如下:
class etchostfile
(
$hostfile
)
file { $hostfile :
ensure => file,
source => "file:///var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
}
然后我定义了一个节点:
node 'hostname.fqdn.com'
{
class { 'etchostfile' :
hostfile => foo,
}
}
我希望它获取文件 /var/www/cobbler/pub/hosts-foo.txt
并将其安装到 /root/hosts
。但我收到此错误:
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Could not
retrieve information from environment production source(s)
file:///var/www/cobbler/pub/hosts-foo.txt
文件存在,可读,每个指向它的目录至少为 r-x。
我看到此错误适用于不正确的 puppet:///
源的原因有很多,但我使用的是 file:///
源。我还尝试在代理和主机上禁用 SELinux。运气不好。
它在我的测试主机上运行正常,所以我认为这是防火墙问题。但是agent可以在8140端口上到master,而且我已经有签名证书了,看来至少拿到了一个目录,所以我不明白为什么我也拿不到文件
看起来您正试图从您的人偶大师那里获取文件?在这种情况下,您需要使用 puppet:// 资源而不是 file:// 资源。
此外,请确保您在 master 上的文件服务器设置正常工作。
https://docs.puppetlabs.com/guides/file_serving.html#file-server-configuration
[编辑]
来自上面链接文档的第一段:
If a file resource declaration contains a puppet: URI in its source
attribute, nodes will retrieve that file from the master’s file server
此外,还有一些文档在讨论文件源属性
https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source
如果您尝试引用本地文件(代理所在节点的本地文件 运行),您可以删除协议部分并仅使用:
file { $hostfile :
ensure => file,
source => "/var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
如果您尝试访问 puppet master 上的文件,则需要使用 puppet:///
协议(而不是文件)。这将带来一些额外的限制:通常您不会将 puppet 文件服务配置为服务于 master 上的所有文件(这将是一个安全问题),而是仅服务于属于 puppet 模块的文件。
或者您可以使用没有逻辑的模板代替文件:
file { $hostfile :
ensure => file,
content => template("my_module/hosts-${hostfile}.txt.erb"),
path => '/root/hosts',
}
这是违反直觉的,但是使用没有逻辑的模板往往比尝试使用 Puppet 进行文件服务具有更好的性能。
我有一个人偶 class 定义如下:
class etchostfile
(
$hostfile
)
file { $hostfile :
ensure => file,
source => "file:///var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
}
然后我定义了一个节点:
node 'hostname.fqdn.com'
{
class { 'etchostfile' :
hostfile => foo,
}
}
我希望它获取文件 /var/www/cobbler/pub/hosts-foo.txt
并将其安装到 /root/hosts
。但我收到此错误:
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Could not
retrieve information from environment production source(s)
file:///var/www/cobbler/pub/hosts-foo.txt
文件存在,可读,每个指向它的目录至少为 r-x。
我看到此错误适用于不正确的 puppet:///
源的原因有很多,但我使用的是 file:///
源。我还尝试在代理和主机上禁用 SELinux。运气不好。
它在我的测试主机上运行正常,所以我认为这是防火墙问题。但是agent可以在8140端口上到master,而且我已经有签名证书了,看来至少拿到了一个目录,所以我不明白为什么我也拿不到文件
看起来您正试图从您的人偶大师那里获取文件?在这种情况下,您需要使用 puppet:// 资源而不是 file:// 资源。
此外,请确保您在 master 上的文件服务器设置正常工作。
https://docs.puppetlabs.com/guides/file_serving.html#file-server-configuration
[编辑] 来自上面链接文档的第一段:
If a file resource declaration contains a puppet: URI in its source attribute, nodes will retrieve that file from the master’s file server
此外,还有一些文档在讨论文件源属性 https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source
如果您尝试引用本地文件(代理所在节点的本地文件 运行),您可以删除协议部分并仅使用:
file { $hostfile :
ensure => file,
source => "/var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
如果您尝试访问 puppet master 上的文件,则需要使用 puppet:///
协议(而不是文件)。这将带来一些额外的限制:通常您不会将 puppet 文件服务配置为服务于 master 上的所有文件(这将是一个安全问题),而是仅服务于属于 puppet 模块的文件。
或者您可以使用没有逻辑的模板代替文件:
file { $hostfile :
ensure => file,
content => template("my_module/hosts-${hostfile}.txt.erb"),
path => '/root/hosts',
}
这是违反直觉的,但是使用没有逻辑的模板往往比尝试使用 Puppet 进行文件服务具有更好的性能。