木偶:如果angular色匹配,层次结构如何工作?

我想了解Puppet层次结构如何工作。

我的Puppet服务器的hiera.yaml如下所示:

 [root@puppet puppet]# cat hiera.yaml :backends: - yaml :yaml: :datadir: '/etc/puppet/hieradata/%{::environment}' :hierarchy: - fqdns/%{::fqdn} - roles/%{::role} - domains/%{::domain} - common 

我想要所有的服务器都有模块,所以我把它们放在common.yaml文件中,每个role.yaml文件中都包含了特定于angular色的模块。

当匹配Puppet中angular色的服务器启动时,首先加载role.yaml文件中的模块。 我的问题是:一旦一台服务器与一个angular色匹配…它会停在那里? 或者它会继续在层次结构中,并加载common.yaml下的模块?

如果不是,我怎样才能确保这是如何performance?

编辑#1:这是一个role.yaml文件的例子:

 [root@puppet roles]# cat dataorigin.yaml classes: - workspace jdk_enable: true jdk_ver: 1.6.0_41 component_ver: 1-1-5-17 tomcat_enable: true debug_mode: true fstab_params: mount1: mnt_src: "isilonnj01.eyedcny.local:/ifs/Peer39/do_share" mnt_dest: "/doshare" mnt_opts: "tcp,hard,intr,noatime" mnt_dest_parent: "" 

服务器的site.pp如下所示:

 hiera_include("classes", []) Package { allow_virtual => false, } node default { include stdlib } 

编辑#2:这是一个motd模块的例子:

 include stdlib class motd { file { "/etc/custom_motd.sh": path => '/etc/custom_motd.sh', ensure => present, owner => "root", group => "root", mode => "775", content => template('motd/custom_motd.sh.erb'), #require => Class['nagios_client'], } file_line { 'enable motd': ensure => present, line => '/etc/custom_motd.sh', path => '/etc/profile', require => File['/etc/custom_motd.sh'] } } 

motd modulecommon.yaml文件中configuration,而在role.yaml文件中有一个称为workspace的模块。 我如何告诉木偶common.yaml文件加载motd module

Hiera是查找数据的工具。 你给它一个关键的名字,它遍历它的数据文件,并返回它的第一个匹配(应该是最具体的),在它的层次结构中向下遍历。

在傀儡中使用它 ,如果一个键有多个值,你可以有更多的select:

 hiera Standard priority lookup. Gets the most specific value for a given key. This can retrieve values of any data type (strings, arrays, hashes) from Hiera. hiera_array Uses an array merge lookup. Gets all of the string or array values in the hierarchy for a given key, then flattens them into a single array of unique values. hiera_hash Uses a hash merge lookup. Expects every value in the hierarchy for a given key to be a hash, and merges the top-level keys in each hash into a single hash. Note that this does not do a deep-merge in the case of nested structures. 

使用hiera作为ENC加载模块就像这样 (强调添加):

请注意, hiera_include函数使用数组合并查找来检索类数组; 这意味着每个节点将从其层次结构中获取每个类。

因此,如果您遵循文档并使用了hiera_include ,则会加载您在整个层次结构中为节点指定的所有类。

在你的例子中,假设role=dataorigin ,那common.yaml看起来像这样:

 --- classes: - a 

您的site.pp将导致模块workspace stdliba被分配给查询节点。