Ask Your Question
0

How to define nodes from a Hiera file in Puppet?

asked 2013-11-12 02:40:17 -0500

Pigueiras gravatar image

I am using 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:

nodes:
  - node1
  - node2

config_device:
  node1:
    custom_parameter: "whatever1"
  node2 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-12 08:04:43 -0500

llowder gravatar image

What I would recommend is that you create a series of classes for these interfaces. Make the classes paramaterized.

In your hiera data, you can then use databindings / autolookup to supply the information for those params.

Then add a layer to your hierarchy based on the the certname fact (if you have tons of nodes, you may want to use a custom fact,so you can group the nodes more conveniently).

Within each file (based on certname or the custom fact) you then create an array named classes.

---
#...
classes:
  - foo
  - foo::server

And any classes you want applied to all ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-11-12 02:40:17 -0500

Seen: 316 times

Last updated: Nov 12 '13