Search code examples
puppet

Puppet: Error 400 Could not find any files


I double checked all settings but did not find the issue and that's why I try to get help here.

Let me show the configuration:

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 *
[...]

Now whenever I run Puppet and it tries to implement a specific file I get this:

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

Note that I had to replace sensitive information by xy but for debugging purposes I try to give every detail where possible. So /sites points to /etc/puppet/environments/production/sites/ according to fileserver.conf and the directory exists like this (with correct permissions imho):

/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/

The mentioned file puppet:///sites/xy/files/xy/xy.key.pub should therefore be located in /etc/puppet/environments/production/sites/xy/files/xy/xy.key.pub which looks like this:

/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

And the in the error message mentioned line 88 of the module which loads the file it looks like this:

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

where $s0_pubkey is xy.key.pub and ${sitefiles} is sites/$site/files which leads to the evaluated path of the requested file like this: puppet:///sites/xy/files/xy/xy.key.pub


Solution

  • The function file() in Puppet can not handle Puppet mountpoints with puppet://. The official docs at https://docs.puppet.com/puppet/latest/reference/function.html#file don't mention it specifically but obviously without mentioning it it means it can't handle extra mountpoints and wants to load files from a modules files directory.

    My solution: I will use a variable which declares the absolute path to my "sites files" like this: $sitefiles_absolute = "/etc/puppet/environments/${environment}/sites/xy/files/" which will never change or at least not very often. And with keeping it in the site.pp file it can be used on every node and module.