傀儡/傀儡:在傀儡应用的情况下找不到模块类



在厨房收敛期间,调用木偶应用程序,我收到此错误:

Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::alibi for ... at .. entry.pp 

不在场证明是模块名称,并且:

/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

该命令是

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 

如果我使用 init.pp 而不是 entry.pp(但没有调用 hiera_include() ),那没关系

您的代码应正确放置在模块中。 当 Puppet 查找一个名为alibi的类时,它将检查 modulepath 中的每个目录(不清楚您的情况是什么,但可能只是/tmp/kitchen/modules)以查找文件alibi/manifests/init.pp。 工作目录和清单目录是无关紧要的,至少在任何应该在任何地方使用的 Puppet 版本中都是如此。

但是,此特定名称有点特殊,因为它将被解释为模块主类的名称。 同一模块中的其他类和定义的类型映射方式略有不同。 例如,alibi::good将映射到alibi/manifests/good.pp,而alibi::alibi将映射到alibi/manifests/alibi.pp

如果我使用 init.pp 而不是 entry.pp(但没有调用 hiera_include() 没关系)

嗯,是也不是。 Puppet 不依赖于文件映射约定,并且在显式告诉它要评估哪个文件时会检查当前目录。 因此,当您显式命名init.pp时,它会查找并评估该文件。 但是不,单独评估该文件几乎没有用处:Puppet 将解析类声明,但该清单中没有任何内容说明将该类应用于目标节点。

最新更新