Ask Your Question
0

Using hiera without explicit calls

asked 2013-10-17 05:18:26 -0500

deric gravatar image

In some cases I've noticed that it's possible to use hiera whithout being explicitly called (which should be preferred approach). Hiera config:

munin::client::host      : '192.168.1.1'

Which will be auto-magically substitiuted here:

class munin::client(
  $host = '*',
)

This is great. However when I tried it with inheritance it fails:

class fhgfs {
  $mgmtd_host                    = 'localhost'
}

class fhgfs::meta (
  $mgmtd_host     = $fhgfs::mgmtd_host,
) inherits fhgfs {  ... }

hiera config: fhgfs::mgmtd_host: '192.168.1.1'

The value from hiera is never used and always falls back to defaults. What am I doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-17 06:58:09 -0500

gertvdijk gravatar image

In this case I think you should explicitly call hiera() to get the right key, because the automatic parameter lookup doesn't take class inheritance into account. E.g.:

class fhgfs::meta (
  $mgmtd_host     = hiera('hgfs::mgmtd_host')
) inherits fhgfs {  ... }
edit flag offensive delete link more

Comments

Ok, thanks! I want to share some config parameters between few classes, so inheritance it's good for this. That's what I'm using right now: https://github.com/deric/puppet-fhgfs/blob/master/manifests/init.pp

deric gravatar imagederic ( 2013-10-17 08:02:58 -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

1 follower

Stats

Asked: 2013-10-17 05:18:26 -0500

Seen: 106 times

Last updated: Oct 17 '13