converting Hiera v3 to v5 - :merge_behavior: deeper option?

asked 2018-04-26 07:29:06 -0500

damm gravatar image

updated 2018-04-27 10:37:10 -0500

Hi

I am in the process of migrating v3 hiera.yaml to v5 and I would like all hash merges to merge 'deep' by default, the same way :merge_behavior: deeper in v3 parameter provides.

I can't seem to find an easy way to do this after reading the docs - I understand lookup_options: need to be set, however it requires class parameter to be specified. I tried using regex as below and adding it to common.yaml however it does not produce the desired result.

Is there an easy way to just migrate :merge_behavior: deeper to v5?

Thanks, D

lookup_options:
  ".*":
    merge:
      strategy: deep

puppetserver-2.8.1-1.el7 puppet --version 4.10.11

lookup when lookup_options is defined as above (via regex):

root:/etc/puppetlabs/puppet> puppet lookup --node server1 --environment production_linux abc_cron::jobs::list --explain
Searching for "lookup_options"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Merge strategy hash
      Hierarchy entry "Nagios"
        Merge strategy hash
          Path "/etc/puppetlabs/code/environments/production_linux/data/nagios/hostgroups/server1.yaml"
            Original path: "nagios/hostgroups/%{trusted.certname}.yaml"
            Path not found
          Path "/etc/puppetlabs/code/environments/production_linux/data/nagios/contactgroups/server1.yaml"
            Original path: "nagios/contactgroups/%{trusted.certname}.yaml"
            Path not found
          Path "/etc/puppetlabs/code/environments/production_linux/data/nagios/hosts/server1.yaml"
            Original path: "nagios/hosts/%{hostname}.yaml"
            Path not found
      Hierarchy entry "Hosts"
        Path "/etc/puppetlabs/code/environments/production_linux/data/hosts/server1.yaml"
          Original path: "hosts/%{trusted.certname}.yaml"
          No such key: "lookup_options"
      Hierarchy entry "Application role"
        Path "/etc/puppetlabs/code/environments/production_linux/data/approle/cit_.yaml"
          Original path: "approle/%{abc_application}_%{abc_role}.yaml"
          Path not found
      Hierarchy entry "Application environment"
        Path "/etc/puppetlabs/code/environments/production_linux/data/appenv/cit_nonprod.yaml"
          Original path: "appenv/%{abc_application}_%{abc_environment}.yaml"
          Path not found
      Hierarchy entry "Application"
        Path "/etc/puppetlabs/code/environments/production_linux/data/app/cit.yaml"
          Original path: "app/%{abc_application}.yaml"
          No such key: "lookup_options"
      Hierarchy entry "Nagios environment"
        Path "/etc/puppetlabs/code/environments/production_linux/data/nagios/env/server1.yaml"
          Original path: "nagios/env/%{hostname}.yaml"
          Path not found
      Hierarchy entry "Location"
        Path "/etc/puppetlabs/code/environments/production_linux/data/location/london.yaml"
          Original path: "location/%{abc_location}.yaml"
          No such key: "lookup_options"
      Hierarchy entry "Environment"
        Path "/etc/puppetlabs/code/environments/production_linux/data/env/nonprod.yaml"
          Original path: "env/%{abc_environment}.yaml"
          Path not found
      Hierarchy entry "OS release"
        Path "/etc/puppetlabs/code/environments/production_linux/data/osrelease/RedHat_7.yaml"
          Original path: "osrelease/%{os.family}_%{os.release.major}.yaml"
          No such key: "lookup_options"
      Hierarchy entry "OS"
        Path "/etc/puppetlabs/code/environments/production_linux/data/os/RedHat_internal.yaml"
          Original path: "os/%{os.family}_%{abc_infrastructure}.yaml"
          No such key: "lookup_options"
      Hierarchy entry "Common defaults"
        Path "/etc/puppetlabs/code/environments/production_linux/data/common.yaml"
          Original path: "common.yaml"
          Found key: "lookup_options" value: {
            ".*" => {
              "merge" => "deep"
            }
          }
      Merged result: {
        ".*" => {
          "merge" => "deep"
        }
      }
  Module data provider for module "abc_cron" not found
Searching for "abc_cron::jobs::list"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "Nagios"
      Path "/etc/puppetlabs/code/environments/production_linux/data ...
(more)
edit retag flag offensive close merge delete

Comments

Are you able to make a basic lookup? Can you please edit your question and provide error output of lookup command with --explain parameter?

Mr_Sharma gravatar imageMr_Sharma ( 2018-04-27 08:35:04 -0500 )edit

Hi rajeevsharma I uploaded lookup logs as requested

damm gravatar imagedamm ( 2018-04-27 09:41:54 -0500 )edit