人偶:错误 400 找不到任何文件

Puppet: Error 400 Could not find any files

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

让我展示配置:

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 中的函数 file() 无法使用 puppet:// 处理 Puppet 挂载点。 https://docs.puppet.com/puppet/latest/reference/function.html#file 的官方文档没有具体提到它,但显然没有提到它意味着它无法处理额外的挂载点并且想要从模块文件目录加载文件。

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