I am using puppet and the puppet network device management module and I am trying to build my custom type.

In the built-in type for the routers configuration, you can specify a list of nodes and then the configuration inside that node:

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 

What I am trying to do, is to move the manifest declaration of the nodes and the configuration of my custom type to a Hiera file like this one:

  - node1
  - node2

    custom_parameter: "whatever1"
    custom_parameter: "whatever2" 

And then in the manifest iterate over the hiera file creating the nodes with the configuration of each node with something like (I am taking as reference this question in serverfault):

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: }

But for this solution I have two problems, I can not define a node inside a define and I can not parameterize a node name. So, is there any way to declare nodes from a Hiera file with their configuration inside?


Why do you want to describe all nodes in one hiera file? What makes hiera superb is its hierarchical configuration. Use separate configuration files for separate hierarchy layers and finally have separate hiera file for separate node. And all of these layers will be merged together.

  • I don't know if you understood me. I am not using puppet in a standard way, I am trying to use {{puppet device}} to configure devices onbehalf. I am looking for a way to place all the device configuration in one hiera file, because I don't want the people that manage the configuration of the devices to edit the manifests. – Pigueiras Nov 12 '13 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.