From 96bfd3edb1e78b3ecebf3b8673277ce3f6a96f62 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Thu, 16 May 2024 10:52:55 -0700 Subject: [PATCH] Knockout prefix reproduction --- examples/hiera/data/common.yaml | 4 +++- examples/hiera/data/dc1.yaml | 1 + examples/hiera/data/production.yaml | 2 ++ examples/hiera/hiera.yaml | 6 ++++-- lib/puppet/pops/merge_strategy.rb | 4 +++- 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 examples/hiera/data/production.yaml diff --git a/examples/hiera/data/common.yaml b/examples/hiera/data/common.yaml index 693fb02b70a..425bcd5bb51 100644 --- a/examples/hiera/data/common.yaml +++ b/examples/hiera/data/common.yaml @@ -9,4 +9,6 @@ ntp::config::ntpservers: lookup_options: classes: - merge: unique + merge: + strategy: deep + knockout_prefix: -- diff --git a/examples/hiera/data/dc1.yaml b/examples/hiera/data/dc1.yaml index 4aa3a476cbc..a113c75d8a7 100644 --- a/examples/hiera/data/dc1.yaml +++ b/examples/hiera/data/dc1.yaml @@ -3,4 +3,5 @@ ntp::config::ntpservers: - 'ntp1.dc1.example.com' - 'ntp2.dc1.example.com' classes: + - --ntp::config - users::dc1 diff --git a/examples/hiera/data/production.yaml b/examples/hiera/data/production.yaml new file mode 100644 index 00000000000..b94e4f0de80 --- /dev/null +++ b/examples/hiera/data/production.yaml @@ -0,0 +1,2 @@ +--- +classes: diff --git a/examples/hiera/hiera.yaml b/examples/hiera/hiera.yaml index 09d46a91301..5ec287d3541 100644 --- a/examples/hiera/hiera.yaml +++ b/examples/hiera/hiera.yaml @@ -6,10 +6,12 @@ defaults: hierarchy: - name: 'Per Location' - path: "%{facts.location}.yaml" + path: 'dc1.yaml' + #%{facts.location}.yaml" - name: 'Per Environment' - path: "%{facts.environment}.yaml" + path: 'production.yaml' + # path: "%{facts.environment}.yaml" - name: 'Common Data' path: 'common.yaml' diff --git a/lib/puppet/pops/merge_strategy.rb b/lib/puppet/pops/merge_strategy.rb index c79d445e051..f78537132ef 100644 --- a/lib/puppet/pops/merge_strategy.rb +++ b/lib/puppet/pops/merge_strategy.rb @@ -373,7 +373,9 @@ def checked_merge(e1, e2) dm_options = { :preserve_unmergeables => false } options.each_pair { |k, v| dm_options[k.to_sym] = v unless k == 'strategy' } # e2 (the destination) is deep cloned to avoid that the passed in object mutates - DeepMerge.deep_merge!(e1, deep_clone(e2), dm_options) + rval = DeepMerge.deep_merge!(e1, deep_clone(e2), dm_options) + puts "Merging #{e1.inspect} with #{e2.inspect} result #{rval.inspect}" + rval end def deep_clone(value)