Ask Your Question

Generate nodes.pp

asked 2015-08-27 06:00:12 -0600 gravatar image

Hi All,

We have many servers in our production environment with different starting name Like some of them starts with

FSL or LC or ulvd.

different node have different functions. So my intention is to have base node inherited all + other modules which will be executed only on those sets of hosts. Please suggest how i can achieve this to create nodes.pp.

Thanks in advance

Best regards

Ankit Jain

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-08-28 14:11:36 -0600

mat1010 gravatar image

You could use different ruby functions as well to cut your hostnames into pieces and assign those pieces to variables to work with. Those variables are then available through hiera as well.

Let's say your hostname looks like this

$project  = inline_template("<%= fqdn.split('-')[0] %>")
$hosttype = inline_template("<%= fqdn.split('-')[1].split('.')[0] %>")

node default {
  include profiles::all
  include roles::$project::$hosttype

This will interpolate to something like this

node default {
  include profiles::all
  include roles::puppet::web
edit flag offensive delete link more


Yes this is also a nice idea. Thanks for your help gravatar ( 2015-08-31 05:03:26 -0600 )edit

answered 2015-08-27 17:47:08 -0600

lavaman gravatar image

updated 2015-08-27 17:48:48 -0600

You can use regex matching in node names:


edit flag offensive delete link more


Thanks It works gravatar ( 2015-08-31 05:03:04 -0600 )edit

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


Asked: 2015-08-27 06:00:12 -0600

Seen: 79 times

Last updated: Aug 28 '15