Ask Your Question

Hiera parameter lookup, nesting variables and Puppet 3

asked 2013-01-30 11:59:53 -0500

EJSarge gravatar image

updated 2013-02-27 09:12:05 -0500

llowder gravatar image

I'm trying to reconcile the advice in the Puppet 3 class doc with our current use of Hiera. We currently retrieve variables from Hiera in one big collection while the Puppet 3 doc seems to indicate storing variables without the collection.

For example, we have a module to manage a log indexer. In its init.pp it says:

class log_indexer(
  $log_indexer_conf = hiera_hash('log_indexer_conf'),

  class {'log_indexer::config':
    log_indexer_conf => $log_indexer_conf}

One of the templates used says: <%= @log_indexer_conf['elasticsearch_cluster_name'] %>

The associated log_indexer.yaml for Hiera is:

  elasticsearch_cluster_name: 'van-test-elasticsearch-cluster'

The Puppet 3 Class docs say,

Be sure to use 3 ...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-30 19:44:17 -0500

jsweeny gravatar image

If you are building the hash from multiple YAML files, calling hiera_hash() in the parameter definition is the only way to do it. However, if you are retrieving a hash defined in a single YAML file, you don't actually want to be using hiera_hash(). Hiera will return any supported data type with just the hiera() call, including hashes and arrays. The hiera_hash() and hiera_array() functions are to build those data structures out of multiple files.

That said, to your question regarding the key names, I do recommend that you follow the classname::key pattern, since not only does it ... (more)

edit flag offensive delete link more

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-01-30 11:59:53 -0500

Seen: 3,185 times

Last updated: Jan 30 '13