Ask Your Question
16

An end to end role/profile example using hiera?

asked 2013-06-13 16:13:03 -0600

ramindk gravatar image

updated 2013-08-30 18:11:46 -0600

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
27

answered 2013-06-13 16:16:20 -0600

ramindk gravatar image

updated 2014-02-09 22:30:38 -0600

I do not think there has been a complete example because it requires a mildly complex example to show the benefits.

In this example we're going to build an haproxy.cfg for some machines named proxy[01-09] using defines fed by hashes in Hiera. The advantage of this approach is that your code can consume data to generate the config programatically. When you build a new class of servers, perhaps use HAProxy in front of Redis, you do not need to refactor or even revisit the code, you merely add the appropriate data to Hiera and add the profile ... (more)

edit flag offensive delete link more

Comments

Is "environment" also a custom fact?

Red Cricket gravatar imageRed Cricket ( 2014-01-22 12:00:23 -0600 )edit

No it's the standard Puppet environment fact.

ramindk gravatar imageramindk ( 2014-01-22 15:39:15 -0600 )edit

Thanks for responding. Does environment evaluate to "production" or "stage" ? Is that why you have files "/etc/puppet/hieradata/production/proxy.yaml" and "/etc/puppet/hieradata/stage/proxy.yaml"? My ...(more)

Red Cricket gravatar imageRed Cricket ( 2014-01-22 16:58:28 -0600 )edit
1

On my servers it does. However the fact environment is only set by the agent when it talks to the master so you won't see it in a facter ...(more)

ramindk gravatar imageramindk ( 2014-01-22 17:25:04 -0600 )edit

I think the notion of roles & profiles is a bit misleading in that it really amounts to using composition instead of inheritance. Take a look at my answer and article ...(more)

quickshiftin gravatar imagequickshiftin ( 2014-01-22 21:24:18 -0600 )edit
2

answered 2014-01-22 21:21:28 -0600

quickshiftin gravatar image

updated 2014-01-22 21:22:39 -0600

Take a peak at my recent article. There's actually a preliminary article that you can read if you want but don't need to. The point of the article is that roles and profiles essentially boils down to one thing. Namely, sometimes you need to use composition instead of inheritance.

Since roles can be implemented as modules, there's really nothing special to using them with hiera. You can use hiera_include to declare a role from hiera just like any other module. The only difference is a role groups a set of lower-level modules for reuse across nodes.

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

9 followers

Stats

Asked: 2013-06-13 16:13:03 -0600

Seen: 36,207 times

Last updated: Feb 09 '14