如何在Puppet中定义Hiera文件中的节点?

我使用木偶和傀儡networking设备pipe理模块 ,我正在尝试构build自定义types。

在路由器configuration的内置types中,可以指定节点列表,然后指定该节点内的configuration:

node "c2950.domain.com" { Interface { duplex => auto, speed => auto } interface { "FastEthernet 0/1": description => "--> to end-user workstation", mode => access, native_vlan => 1000 # [...] More configuration } 

我正在尝试做的是将节点的清单声明和我的自定义types的configuration移动到像这样的Hiera文件:

 nodes: - node1 - node2 config_device: node1: custom_parameter: "whatever1" node2: custom_parameter: "whatever2" 

然后在清单迭代在hiera文件创build节点与每个节点的configuration类似的东西(我在服务器故障中引用这个问题 ):

 class my_class { $nodes = hiera_array('nodes') define hash_extract() { $conf_hash = hiera_hash("config_device") $custom_paramter = $conf_hash[$name] ## TRICK lies in $name variable node $name { my_custom_device { $name: custom_parameter => $device_conf['custom_parameter'] } } } hash_extract{$pdu_names: } } } 

但是对于这个解决scheme我有两个问题,我不能在一个define里面定义一个node ,我不能参数化一个节点的名字。 那么,有没有什么办法从里面的configurationHiera文件中声明节点?

为什么要描述一个hiera文件中的所有节点? 是什么让hiera精湛的是它的分层configuration。 为单独的层次结构层使用单独的configuration文件,最后为单独的节点分别使用hiera文件。 所有这些层将被合并在一起。