Hiera Hash Merge Issues

100 views
Skip to first unread message

Leonard Smith

unread,
Jun 3, 2016, 2:42:45 PM6/3/16
to Puppet Users
I've been trying to track down a problem with hiera_hash not merging.

puppet-3.8.6-1.el7
hiera-1.3.4-1.el7

## hiera.yaml
:hierarchy:
  - test
  - common

## test.yaml
---
rabbitmq_profile::vhosts:
  'test' :
    ensure: present

## common.yaml
---
rabbitmq_profile::vhosts:
  '/' :
    ensure: present

## rabbitmq_profile.pp

class rabbitmq_profile (

$vhosts = hiera_hash('rabbitmq_profile::vhosts',{})

) {

  notify { "<>$vhosts": }
  create_resources(rabbitmq_vhost, $vhosts )
}

## END


When I apply the manifest it creates the vhost specified in test.yaml but not the one in comon.yaml. I expected it to merge the has from both yamls and create the '/' and 'test' vhosts.

 If I remove test from hiera.yaml it creates the '/' vhost fine. I've tried setting the merge_behavior explicitly to native, deep and deeper, but I still see the behavior where it picks up the hash form the first yaml file it encounters and ignores the rest.


Dan White

unread,
Jun 3, 2016, 2:45:43 PM6/3/16
to puppet...@googlegroups.com
Have you tried hiera command line debugging ?
Dan White | d_e_...@icloud.com
------------------------------------------------
“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)
--
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/9073d972-61d4-4454-bf0a-8dad4f889062%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Kristolaitis

unread,
Jun 3, 2016, 2:47:45 PM6/3/16
to puppet...@googlegroups.com
Did you install the deep_merge gem when using the deeper merge option?  The gem is required when using deep or deeper merging.

Dan White

unread,
Jun 3, 2016, 2:49:20 PM6/3/16
to puppet...@googlegroups.com
Better suggestion.
Thanks, Peter.
Dan White | d_e_...@icloud.com
------------------------------------------------
“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)

Leonard Smith

unread,
Jun 3, 2016, 2:57:16 PM6/3/16
to Puppet Users
Deep gem is installed. However this should work with native correct if all I am looking to have it do is create both '/' and 'test' vhost, without ovverriding each other.

Dan White

unread,
Jun 3, 2016, 2:59:35 PM6/3/16
to puppet...@googlegroups.com
UNless the hiera.yaml you provided is incomplete, you did not tur on deep merging.

Dan White | d_e_...@icloud.com
------------------------------------------------
“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)

Leonard Smith

unread,
Jun 3, 2016, 3:03:33 PM6/3/16
to Puppet Users
Clarificaiton. I had tried in the hiera.yaml setting

:merge_behavior: deeper
 
the 
:merge_behavior: deep

and

:merge_behavior: native.

I unset it as well as from my understanding, from the documentation I am not concerned with deep merging. I just want to be able to specify two non-colliding 'vhosts' in two different YAML files and have both be created. The deep/deeper is only needed if the same key  exists and I want to merge the underlying key/values. 

Dan White

unread,
Jun 3, 2016, 3:05:16 PM6/3/16
to puppet...@googlegroups.com
Try command line.  Use the debug option
Dan White | d_e_...@icloud.com
------------------------------------------------
“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)
--
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.

Ramin K

unread,
Jun 3, 2016, 3:05:27 PM6/3/16
to puppet...@googlegroups.com
That looks correct and you are also correct that the deep merge gem is
not required for simple top level key merges. Only for sub keys. I
believe the hiera_hash merge example here is still valid,
https://ask.puppet.com/question/13592/when-to-use-hiera-hiera_array-and-hiera_hash/

## rabbitmq_profile.pp
class rabbitmq_profile (
$vhosts = hiera_hash('rabbitmq_profile::vhosts',{})
) {

I'd make sure that actually the code you're using. If you're using hiera
or databindings it'll default to hiera() as well. That would certainly
explain the behavior you're seeing.

You might try running the master in debug so you can see the hiera
lookups it's attempting.

Ramin
>> send an email to puppet-users...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit
>> <https://groups.google.com/d/msgid/puppet-users/9073d972-61d4-4454-bf0a-8dad4f889062%40googlegroups.com?utm_medium=email&utm_source=footer>https://groups.google.com/d/msgid/puppet-users/9073d972-61d4-4454-bf0a-8dad4f889062%40googlegroups.com
>> <https://groups.google.com/d/msgid/puppet-users/9073d972-61d4-4454-bf0a-8dad4f889062%40googlegroups.com>.
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/dda7b1bd-3380-48dc-89d8-5a5c64d5fce0%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/dda7b1bd-3380-48dc-89d8-5a5c64d5fce0%40googlegroups.com?utm_medium=email&utm_source=footer>.

Leonard Smith

unread,
Jun 3, 2016, 4:08:42 PM6/3/16
to Puppet Users
I'm having a little trouble verify via the command line because we are using the 'module_data' backend so the hiera data in question is specific to the module. But when I query the data via the module directly it works as expected

% hiera --hash -c ./hiera.yaml rabbitmq_profile::vhosts
WARN: 2016-06-03 15:52:02 -0400: Not using Hiera::Puppet_logger. It does not report itself to be suitable.
{"/"=>{"ensure"=>"present"},
 "p2"=>{"ensure"=>"present"},
 "test"=>{"ensure"=>"present"}}

So it might be something with the way module_data is requesting.

On Friday, June 3, 2016 at 2:42:45 PM UTC-4, Leonard Smith wrote:
Reply all
Reply to author
Forward
0 new messages