Hiera testing

42 views
Skip to first unread message

Alfredo De Luca

unread,
Mar 18, 2015, 7:07:15 PM3/18/15
to puppet...@googlegroups.com
Hi all.
I am testing hiera in our enviroment and I wonder if I can manage
everything from hiera without using the main site.pp.

Do you think is the right way? or I should use site.pp as well?


Here is what I am testing and so far so good.

--------- hiera.yaml
---
:backends:
- yaml

:hierarchy:
- "environments/%{::environment}"
- "nodes/%{::fqdn}"
- common

:yaml:
:datadir: /etc/puppet/hieradata/


--------- hiera.yaml

--------- common.yaml
---
classes:
- ntp
- resolver
- yum
- motd

ntp::restrict:
ntp::autoupdate: false
ntp::service_enable: true
ntp::service_ensure: running
ntp::servers:
- 10.4.123.3
- 10.4.123.4
- 10.5.123.3
- 10.5.123.4

resolver::search:
- xxx.xxx.com
resolver::dns_servers:
- 10.4.17.18
- 10.4.17.20
- 10.5.17.18
- 10.5.17.20

yum::source_repo_dir: 'puppet:///REPO_FILES/'
yum::clean_repos: true

motd::content: '##### TEST #####'
--------- common.yaml



--
Alfredo

Alfredo De Luca

unread,
Mar 19, 2015, 8:35:56 AM3/19/15
to puppet...@googlegroups.com
Hi all.
Anyone on this question?
--
Alfredo

Dan White

unread,
Mar 19, 2015, 8:47:04 AM3/19/15
to puppet...@googlegroups.com
My current site.pp sets a few global level variables and then all I need is :

node default {
        hiera_include('classes')
}

I am not sure what kind of response you are looking for.
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”  (Bill Waterson: Calvin & Hobbes)



--
Alfredo

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAAWpFTFRCjdGWPiap_%3D8ZoxyPvuc50a-aLLKSpjjQTF-1jxD9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Denmat

unread,
Mar 19, 2015, 8:48:09 AM3/19/15
to puppet...@googlegroups.com
Yes, I think it's a good way to go, Alfredo.

I would normally have a hierarchy like the following.
- secrets (e-yaml-gpg)
- nodes
- environment
- roles
- common

Gets by in most setups. You'll still need a site.pp file but in can just have:
hiera_include('classes') (pretty sure that's the call, not at a my laptop).

You can also do something to handle default nodes (ones that don't match the hiera data yet) by having one default node specified in your site.pp Up to you.

HTH,
Den

jcbollinger

unread,
Mar 19, 2015, 8:50:37 AM3/19/15
to puppet...@googlegroups.com


On Wednesday, March 18, 2015 at 6:07:15 PM UTC-5, Alfredo De Luca wrote:
Hi all.
I am testing hiera in our enviroment and I wonder if I can manage
everything from hiera without using the main site.pp.

Do you think is the right way? or I should use site.pp as well?


Hiera does not classify nodes.  You need a site manifest or an ENC, or both.  You can use Hiera similarly to an ENC, however, with a little bit of glue in your site manifest.  Supposing that an array of the classes designated for a given node are available via array-merge lookup of the hiera key 'classes', as you show, you can put this at the top level of the site manifest:

hiera_include('classes')

Given that, it is conceivable that you could do without anything else in your site manifest, and without an actual ENC.

Note that the 'classes' key is not special to Hiera.  It is distinguished from any other random string only by the way your manifests use it.


John

Garrett Honeycutt

unread,
Mar 19, 2015, 10:28:22 AM3/19/15
to puppet...@googlegroups.com
Hi Alfredo,

Here is a link[1] to the site manifest that I use. Everything else is
driven through Hiera. Your hierarchy should be ordered such that the
most specific level is first and each subsequent level describes your
systems with less specificity. So the fqdn level should be swapped with
the environment. Here is a link[2] to a good starting point for your
hiera configuration.

If you were to visualize the number of keys in each level of the
hierarchy it would appear as a pyramid with the the top having the
fewest keys and the bottom having the most. If you find that's not the
case, it is a good sign to refactor your hiera levels.

[1] - https://gist.github.com/ghoneycutt/14855c4890cb400165f3
[2] - https://gist.github.com/ghoneycutt/5b6034f9bb381c56a950

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Alfredo De Luca

unread,
Mar 19, 2015, 6:58:52 PM3/19/15
to puppet...@googlegroups.com
Hi Garrett et all.

Thanks for your thoughts and examples. I forgot to mention and I have
in my top level site.pp only
hiera_include('classes')
and the rest it's in the hiera.yaml mentioned above and so far so good.
I was just wondering if it's one way to go and it seems to be right.

I love Puppet and Hiera....

Thanks guys again
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/550ADCFB.8020705%40garretthoneycutt.com.
> For more options, visit https://groups.google.com/d/optout.



--
Alfredo
Reply all
Reply to author
Forward
0 new messages