Ask Your Question
0

Generate nodes.pp

asked 2015-08-27 06:00:12 -0500

ankitjain@freescale.com 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
0

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

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 puppet-web.example.com

$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

Comments

Yes this is also a nice idea. Thanks for your help

ankitjain@freescale.com gravatar imageankitjain@freescale.com ( 2015-08-31 05:03:26 -0500 )edit
0

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

lavaman gravatar image

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

You can use regex matching in node names:

regular-expression-names

edit flag offensive delete link more

Comments

Thanks It works

ankitjain@freescale.com gravatar imageankitjain@freescale.com ( 2015-08-31 05:03:04 -0500 )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

Stats

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

Seen: 74 times

Last updated: Aug 28 '15