During a kitchen converge, calling a puppet apply, i got this error :
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::alibi for ... at .. entry.pp
alibi is the module name, and :
/tmp/kitchen>ll
total 8
drwxrwxr-x. 4 kitchen kitchen 80 Feb 26 14:14 hiera
-rw-rw-r--. 1 kitchen kitchen 170 Feb 26 14:14 hiera.global.yaml
drwxrwxr-x. 2 kitchen kitchen 100 Feb 26 14:35 manifests
drwxrwxr-x. 4 kitchen kitchen 80 Feb 26 14:14 modules
-rw-rw-r--. 1 kitchen kitchen 901 Feb 26 13:53 puppet.conf
/tmp/kitchen>more manifests/entry.pp manifests/init.pp
::::::::::::::
manifests/entry.pp
::::::::::::::
hiera_include('classes')
::::::::::::::
manifests/init.pp
::::::::::::::
class alibi () {
$instances = hiera_hash("alibi::instances", {})
validate_hash($instances)
create_resources("alibi::instance", $instances)
}
/tmp/kitchen>/tmp/kitchen>more hiera.global.yaml
---
:backends:
- yaml
:yaml:
:datadir: "/tmp/kitchen/hiera"
:hierarchy:
- tests/%{hostname}
- origin/main
# options are native, deep, deeper
:merge_behavior: deeper
/tmp/kitchen>/tmp/kitchen>more hiera/origin/main.yaml
classes:
- alibi
The command is
export MANIFESTDIR='/tmp/kitchen/manifests'; sudo -E env
http_proxy=http://proxy-internet.localnet:3128
https_proxy=http://proxy-internet.localnet:3128 puppet apply
/tmp/kitchen/manifests/entry.pp --modulepath=/tmp/kitchen/modules
--fileserverconfig=/tmp/kitchen/fileserver.conf
--hiera_config=/tmp/kitchen/hiera.global.yaml --detailed-exitcodes -v
Its ok if I use init.pp instead of entry.pp (but hiera_include() is not called)
Your code should be properly placed in modules. When Puppet looks for a class named alibi
, it will check each directory in your modulepath (unclear what that is in your case, but possibly just /tmp/kitchen/modules
) for a file alibi/manifests/init.pp
. The working directory and manifest directory are irrelevant, at least in any version of Puppet that ought still to be in use anywhere.
This particular name is a bit of a special case, however, because it will be interpreted as the name of a module's main class. A other classes and defined types in the same module will be mapped a bit differently. For example, alibi::good
would be mapped to alibi/manifests/good.pp
, and alibi::alibi
would be mapped to alibi/manifests/alibi.pp
.
Its ok if I use init.pp instead of entry.pp (but hiera_include() is not called)
Well, yes and no. Puppet does not rely on file mapping conventions and does check the current directory when you explicitly tell it which file to evaluate. Therefore, when you explicitly name init.pp
to it, it finds and evaluates that file. But no, evaluating that file by itself is of little use: Puppet will parse the class declaration, but there is nothing in that manifest that says to apply that class to the target node.