Mixing hiera and site.pp

76 views
Skip to first unread message

Alexander Dacre

unread,
Aug 5, 2015, 8:25:09 AM8/5/15
to Puppet Users
Hi,

I'm going through an initial deployment of Puppet and was looking to use hiera as much as possible, but it seems that many existing modules do not have hiera support.

The question I have is, is it 'OK' to have some bits of configuration for a node defined in hiera, and others in site.pp?

Thanks,
A

Matthew Burgess

unread,
Aug 5, 2015, 8:58:42 AM8/5/15
to puppet...@googlegroups.com
Hi Alexander,

If you use the roles and profiles design pattern [0] then as suggested
at [1], your profile class could look up the required parameters from
hiera, do any validation required on it, then pass that data in as
standard class parameters.

Regards,

Matt.

[0] http://www.craigdunn.org/2012/05/239/
[1] http://garylarizza.com/blog/2014/02/17/puppet-workflow-part-2/
> --
> 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/54ccc36a-7b93-48d4-b8c1-e2eabf098acf%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Aug 6, 2015, 10:47:58 AM8/6/15
to Puppet Users
What do you mean about existing modules not having Hiera support?  Modules do not need special support for Hiera because every parameterized class's parameters can be provided via Hiera.  This is Puppet's automatic data binding feature, and it is by far the most common way that Hiera is used.  It is the only way that parameterized classes' parameters should be assigned from outside their modules.

It is also possible for DSL code to perform explicit data lookups, in which case a module might document specific Hiera keys (different from those corresponding to class parameters) by which module users can provide data.  This is not much done any more, however.


John

Tony Thayer

unread,
Aug 7, 2015, 2:01:01 PM8/7/15
to Puppet Users
I work around this by creating wrapper classes that pull in my hiera data.

example:
class my_apache_config_module (
  $this_hostname = hiera('this_hostname')
){
  apache::vhost { $this_hostname:
    blah => "blah blah"
Reply all
Reply to author
Forward
0 new messages