【问题标题】:Puppet: Error 400 Could not find any filesPuppet:错误 400 找不到任何文件
【发布时间】:2016-10-07 12:43:54
【问题描述】:

我仔细检查了所有设置,但没有发现问题,这就是我尝试在这里寻求帮助的原因。

让我展示一下配置:

puppet.conf:

[...]
[master]
environmentpath     = $confdir/environments/
hiera_config        = $confdir/environments/production/sites/xy/config/hiera.yaml
default_manifest    = ./sites/xy/config/
environment_timeout = 0

fileserver.conf:

[...]
[sites]
   path /etc/puppet/environments/production/sites/
   allow *

auth.conf:

[...]
# extra mountpoint
path /sites
allow *
[...]

现在每当我运行 Puppet 并尝试实现特定文件时,我都会得到:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find any files from puppet:///sites/xy/files/xy/xy.key.pub at /etc/puppet/environments/production/modules/xy/manifests/xy.pp:88 on node xy
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

请注意,我必须用 xy 替换敏感信息,但出于调试目的,我会尽可能提供所有细节。 所以/sites 根据fileserver.conf 指向/etc/puppet/environments/production/sites/ 并且目录是这样存在的(具有正确的权限恕我直言):

/etc/puppet % ls -ld /etc/puppet/environments/production/sites/
drwxr-xr-x 8 root puppet 4096 Oct  7 12:46 /etc/puppet/environments/production/sites/

因此,提到的文件puppet:///sites/xy/files/xy/xy.key.pub 应位于/etc/puppet/environments/production/sites/xy/files/xy/xy.key.pub,如下所示:

/etc/puppet % ls -l /etc/puppet/environments/production/sites/*/files/*/*.key.pub
-rw-r--r-- 1 root puppet 725 Oct  7 12:46 /etc/puppet/environments/production/sites/xy/files/xy/xy.key.pub

并且在错误消息中提到了加载文件的模块的第 88 行,它看起来像这样:

$sshpubkey = file("puppet:///${sitefiles}/xy/${s0_pubkey}")

其中$s0_pubkeyxy.key.pub${sitefiles}sites/$site/files,这导致请求文件的评估路径如下:puppet:///sites/xy/files/xy/xy.key.pub

【问题讨论】:

    标签: puppet


    【解决方案1】:

    Puppet 中的函数file() 无法处理带有puppet:// 的Puppet 挂载点。 https://docs.puppet.com/puppet/latest/reference/function.html#file 的官方文档没有具体提及它,但显然没有提及它意味着它无法处理额外的挂载点并希望从模块文件目录加载文件。

    我的解决方案:我将使用一个变量来声明我的“站点文件”的绝对路径,如下所示:$sitefiles_absolute = "/etc/puppet/environments/${environment}/sites/xy/files/",它永远不会改变,或者至少不会经常改变。并且将其保存在site.pp 文件中,它可以在每个节点和模块上使用。

    【讨论】:

    • 这并不是真正的问题。您希望我们帮助您解决问题,还是对解决方法感到满意?
    • 请继续使用更好的解决方案 :) @MattSchuchard 如果知道正确的原因,我将不胜感激。
    • 我实际上希望 John Bollinger 等人会这样做,因为它需要一个冗长的解释,而且我在度假时感到很懒惰。我可以在几天后重温这个。
    • 所以我会等。谢谢。
    • @MattSchuchard 有什么消息吗?
    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 2021-05-08
    • 1970-01-01
    • 2013-04-19
    • 1970-01-01
    • 1970-01-01
    • 2021-09-02
    • 1970-01-01
    相关资源
    最近更新 更多