manifest
The entry-point manifest for puppet master.
- Default: $manifestdir/site.pp
-
manifestdir
Where puppet master looks for its manifests.
- Default: $confdir/manifests
confdir
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.
- Default: /etc/puppet
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将使用全名来查找它们在你的模块中的位置。查找过程如下:
- The first segment in a name (excluding the empty “top” namespace) identifies the
module. Every class and defined type should be in its own file in the module’s manifests
directory, and each file should have the .pp
file extension. - 名字中的第一节用来识别模块,每个类都应该在自己的文件夹下有一个manifests文件名字的pp文件
- If there are
no additional namespaces, Puppet will look for the class or defined type in the module’s init.pp
file. - Otherwise, Puppet will treat the final segment as the file name and any interior segments as a series of subdirectories under the
manifests
directory. - 如果类名只有第一节,那么Puppet将会找init.pp,如果有两节,将会查找第二节名字对应的pp文件,如果有3节则会查找第2节名字目录下的第3节名字的pp文件,以此类推。
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
.pp
apache.pp
apache::apache
.)
记住只有init.pp中定义与模块名相同的类,其它的类名都至少有::分隔的两节。
由此,我们能看到,Puppet Master是首先加载site.pp,然后通过import nodes/*.pp来加载节点的定义,然后通过命名空间的自动加载来找到对应模块的类的定义。大概过程就是这样。
PS:Puppet对语法和manifests的检查没有那么的严格,比如说,你可以把你的配置都写进site.pp,也可以在init.pp中写多个类,但是为了管理方便,我还是建议你按照它的最佳实践来写。
多看文档,现在Puppet里还有不少坑没解决,多看才能尽量避开。例如,命名空间和自动加载文件里写了如下内容:
Important note: