为什么某些 Puppet 模块中没有 init.pp?

Why is there no init.pp in some Puppet modules?

我发现有些 Puppet 模块没有 init.pp。为什么是这样? init.pp在Puppet模块中的作用是什么?

Puppet 能否找到没有 init.pp 清单的模块?

I found there are some Puppet modules without init.pp. Why? What the function of init.pp in Puppet?

模块 manifests/ 目录中清单文件的布局用于允许自动加载器将模块的 class 和定义的类型名称映射到清单文件。包含 class 定义或 my_module::foo 形式定义类型的清单预计为 my_module/manifests/foo.pp,相对于模块路径中的某个目录。

许多——但不是全部——模块有一个与模块同名的 class。例如,模块 my_module 可能有一个名为 my_module 的 class。这样的 class 不能放在 my_module/manifests/my_module.pp 中,因为那是 my_module::my_module 的位置。相反,如果一个模块有一个同名的 class,那么它的定义会在其清单目录中的 init.pp 中。 (Class 形式的名称 my_module::init 不允许腾出空间。)另一方面,如果模块 提供同名 class或定义的类型,那么 init.pp 将不会包含任何有用的内容;然后可以省略它。

Puppet 文档详细讨论了 autoloading and manifest layout

Can Puppet locate a module without init.pp?

当然可以。 Puppet 不依赖 init.pp 文件的存在来识别模块。模块由模块路径中目录的子目录定义。