Ask Your Question

Getting away with not having dupe Hiera data

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

STOIE gravatar image

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

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:





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

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

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


Perfect solution!

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

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

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:

   prod :
   dev  :

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


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 -0600 )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 -0600 )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 -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


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

Seen: 203 times

Last updated: Mar 25 '13