Ask Your Question
0

Getting away with not having dupe Hiera data

asked 2013-03-24 23:13:01 -0500

STOIE gravatar image

updated 2013-03-24 23:13:41 -0500

Hi all,

I am in a puzzle at the moment, I want to have a specific node see both prod and dev hiera data, but, the rest of my nodes use just their corresponding hiera data.

However, to make this even more confusing, I don't want to have a "in-between" catalog for just this node, that I would have to maintain separately.

For example:

prod.yaml

---
ntp: 1.1.1.2

dev.yaml

---
ntp: 1.1.1.3

Now let's say I want my prod monitoring box to acknowledge both prod and dev... and monitor both.

Is there ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-03-25 11:24:28 -0500

Stefan gravatar image

You can force hiera to search the key in a specified hierarchy level:

$ntp_dev = hiera('ntp_servers', '', 'dev')   # will only look in dev.yaml
$ntp_prod = hiera('ntp_servers', '', 'prod') # will only look in prod.yaml

$ntp_all = [ $ntp_dev, $ntp_prod ]

The array should be automtically flatten in the puppet DSL so if you e.g. say

notify { $ntp_all: }

you'll see one message for each ntp server. If you need the array in a template you may have to flatten the array explicitly otherwise you may see a nested array

# inside template
<% @ntp_all.flatten.each do |ntp_server| -%>
...
<% end -%>
edit flag offensive delete link more

Comments

Perfect solution!

STOIE gravatar imageSTOIE ( 2013-03-26 16:52:16 -0500 )edit
0

answered 2013-03-25 03:04:34 -0500

jonn gravatar image

There are hiera functions to collect data from multiple levels in the hierarchy, but I don't know a way of pulling in data from other hierarchies.

I guess you could maintain the servers as a hash and look them up directly? In common.yaml:

---
ntp_servers:
   prod : 1.1.1.2
   dev  : 1.1.1.3

You get to keep the information in one place, but it makes a bit of a mess of your carefully crafted prod/dev hierarchy!

For monitoring, I'd be tempted to export a resource from the dev/prod servers, and then collect them on ... (more)

edit flag offensive delete link more

Comments

Hi John, your first idea may just work and that would be very easy to implement, however, as you mentioned, it does somewhat kill the purpose of the hiera hierarchy ...(more)

STOIE gravatar imageSTOIE ( 2013-03-25 03:41:22 -0500 )edit

... they are not managed by me, but outsourced and thus I cannot add them to puppet :(

STOIE gravatar imageSTOIE ( 2013-03-25 03:42:17 -0500 )edit

Could you export from the servers that use the hiera ntp resource, as opposed to the ntp servers themselves? Not sure it's any less messy though :(

I'll be ...(more)

jonn gravatar imagejonn ( 2013-03-25 04:57:30 -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

Stats

Asked: 2013-03-24 23:13:01 -0500

Seen: 194 times

Last updated: Mar 25 '13