Hiera hash are not merged between layers
PierreR opened this issue · 8 comments
Given such a call to a hash named 'users' in a pp file $users = lookup('users', Hash, hash, {})
, the hash will not be merged across hiera layers.
Within the same layer, the merge is working but between layers the merge will not happen.
Can you build me a minimal archive that demonstrates the problem? This looks like quite a bit of work to fix at first glance :/
Here is a minimal case.
nix-shell:~/tmp/#277]$ puppetresources -p . -o default --hiera tests/hiera.yaml
ALERT: default: Scope stack :
ALERT: default: class test
ALERT: default: ::
ALERT: default: ::
ALERT: default: Variables in local scope :
ALERT: default: caller_module_name -> ::
ALERT: default: module_name -> test
ALERT: default: name -> test
ALERT: default: title -> test
ALERT: default: users -> { test0 => { home => /nonexistent,
uid => 700}}
class {
test: ./manifests/site.pp:6:3 default [Scope []]
;
}
stage {
main: 1:1 default [Scope []]
;
}
I guess the problem is here:
https://github.com/bartavelle/language-puppet/blob/master/src/Puppet/Interpreter/IO.hs#L105
We don't merge any values across layers in that function.
Thinking about this a bit more, I wonder if there is a (immediate) need to merge from the module layer (because each key needs to be prefix by the module name).
As a first step we could just merge hashes from the global and the environment layers.
I will try to take a good look at this during the weekend.
Thanks.
Forget about my previous comment ...
We do need to merge hashes across all layers. That said the most important is probably to merge hashes from the module layer and the environment layer.
Here is a new test case that is more representative.
I reworked the hiera part a bit, does that work better?
(just fixed the previous commit)
Seems to work nicely so far.
Thanks !