Ask Your Question

hiera_hash fails to fetch values from hieradata when using same variable name - is this a bug?

asked 2016-08-09 02:43:43 -0600

TimmyC gravatar image


class profile::php7web (
  $apache_vhosts_defaults = hiera_hash('profile::php7web::apache_vhosts_defaults'),
) {
  notify { "$apache_vhosts_defaults": }


  port: 80


 setenv: ['SYMFONY_ENV dev']

The output is: setenv: { ['SYMFONY_ENV dev'] } .

However, if I change php7web.pp to:

class profile::php7web (
  $fff = hiera_hash('profile::php7web::apache_vhosts_defaults'),
) {
  notify { "$fff": }

The output is: { port: 80, setenv: ['SYMFONY_ENV dev'] }

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-09 14:43:00 -0600

jorhett gravatar image

updated 2016-08-25 14:57:35 -0600

DarylW gravatar image

So the first one is being set by automatic parameter lookup. The auto lookup finds the highest precedence value of the name on the left and returns it. This is why the first example gets a single, first result value.

If it can't find a variable of the same name, (like "fff") then it uses the backup value you've provided--the hiera_hash() call.

This is working exactly as intended:

That being said, stop using hiera_hash() and use lookup() instead. It is considerably more flexible, and this page describes how to get merged hash results in automatic parameter lookup:

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

1 follower


Asked: 2016-08-09 02:43:43 -0600

Seen: 116 times

Last updated: Aug 25 '16