hiera-eyaml: puppet 4: "merge" parameter of lookup() is not well taken into account with eyaml backend

Hi,

First, thanks to provide hiera-eyaml which is a very useful component (for me). ๐Ÿ˜‰

I have installed a puppet 4 server in a Ubuntu Trusty (puppet-agent 1.3.5 and puppetrserver 2.2.1) and hiera-eyaml is installed too (2.0.8).

Here is my data in the common.yaml file:


---
test:
  array: [ 'a', [ 'b', 'c'] ]
  hash:
    subkey1: 'common-value-subkey1'
    subkey2: 'common-value-subkey2'
  string: 'common-value-string'

In the nodes/trusty-clean.athome.priv.yaml file:


---
test:
  array: [ 'c', 'd' ]
  hash:
    subkey1: 'specific-value-subkey1'
    subkey3: 'specific-value-subkey3'

Here is my hiera.yaml file where I use the eyaml backend:


---
:backends:
  - eyaml

:hierarchy:
  - "nodes/%{::trusted.certname}"
  - common

:eyaml:
  :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
  :pkcs7_private_key: '/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem'
  :pkcs7_public_key: '/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem'
  :extension: 'yaml'

Now, here is the simple code I test:

$fm = lookup('test', Hash, 'first')
notice("first merge: ${fm}")

$hm = lookup('test', Hash, 'hash')
notice("hash  merge: ${hm}")

$dm = lookup('test', Hash, 'deep')
notice("deep  merge: ${dm}")

And if I launch a puppet apply, here is the result:

~# /opt/puppetlabs/bin/puppet apply /tmp/test.pp
Notice: Scope(Class[main]): first merge: {array => [c, d], hash => {subkey1 => specific-value-subkey1, subkey3 => specific-value-subkey3}}
Notice: Scope(Class[main]): hash  merge: {array => [c, d], hash => {subkey1 => specific-value-subkey1, subkey3 => specific-value-subkey3}, string => common-value-string}
Notice: Scope(Class[main]): deep  merge: {array => [c, d], hash => {subkey1 => specific-value-subkey1, subkey3 => specific-value-subkey3}, string => common-value-string}
Notice: Compiled catalog for trusty-clean.athome.priv in environment production in 0.17 seconds

As you can see, I have exactly the same result with hash merge and deep merge, which is not the expected behavior.

Now, if I use the yaml backend (not the eyaml backend) like this:


---
:backends:
  - yaml

:hierarchy:
  - "nodes/%{::trusted.certname}"
  - common

:yaml:
  :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"

In this case, I have the expected behavior where hash merge and deep merge give a different result:

~# /opt/puppetlabs/bin/puppet apply /tmp/test.pp
Notice: Scope(Class[main]): first merge: {array => [c, d], hash => {subkey1 => specific-value-subkey1, subkey3 => specific-value-subkey3}}
Notice: Scope(Class[main]): hash  merge: {array => [c, d], hash => {subkey1 => specific-value-subkey1, subkey3 => specific-value-subkey3}, string => common-value-string}
Notice: Scope(Class[main]): deep  merge: {array => [a, [b, c], c, d], hash => {subkey1 => specific-value-subkey1, subkey2 => common-value-subkey2, subkey3 => specific-value-subkey3}, string => common-value-string}
Notice: Compiled catalog for trusty-clean.athome.priv in environment production in 0.15 seconds
Notice: Applied catalog in 0.02 seconds

Can we consider itโ€™s a bug? Regards.

About this issue

  • Original URL
  • State: open
  • Created 11 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Excellent news, thanks for the detective work @flaf !