The entry-point manifest for puppet master.
Where puppet master looks for its manifests.
The main Puppet configuration directory. The default for this setting is calculated based on the user. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it’s running as any other user, it defaults to being in the user’s home directory.
When a class or defined resource is declared, Puppet will use its full name to find the class or defined type in your modules. Names are interpreted as follows:
当类或自定义资源类型被声明时,Puppet将使用全名来查找它们在你的模块中的位置。查找过程如下:
manifests
directory, and each file should have the .pp
file extension. init.pp
file. manifests
directory. Thus, every class or defined type name maps directly to a file path within Puppet’s modulepath
:
如此,所有的类或自定义类型都对应能找到一个文件
name | file path |
---|---|
apache |
/apache/manifests/init.pp |
apache::mod |
/apache/manifests/mod.pp |
apache::mod::passenger |
/apache/manifests/mod/passenger.pp |
Note again that init.pp
always contains a class or defined type named after the module, and any other.pp
file contains a class or type with at least two namespace segments. (That is, apache.pp
would contain a class named apache::apache
.)
记住只有init.pp中定义与模块名相同的类,其它的类名都至少有::分隔的两节。
由此,我们能看到,Puppet Master是首先加载site.pp,然后通过import nodes/*.pp来加载节点的定义,然后通过命名空间的自动加载来找到对应模块的类的定义。大概过程就是这样。
PS:Puppet对语法和manifests的检查没有那么的严格,比如说,你可以把你的配置都写进site.pp,也可以在init.pp中写多个类,但是为了管理方便,我还是建议你按照它的最佳实践来写。
多看文档,现在Puppet里还有不少坑没解决,多看才能尽量避开。例如,命名空间和自动加载文件里写了如下内容:
Important note: Earlier versions of Puppet used namespaces to navigate nested class/type definitions, and the code that resolves names still behaves as though this were their primary use.This can sometimes result in the wrong class being loaded. This is a major outstanding design issue (issue #2053) which will not be resolved in Puppet 3. See below for a full description of the issue.