cd4user
cd4user

Reputation: 91

Hiera lookup issues after migrating from Hiera 3 to Hiera 5

I've migrated the following Hiera 3 yaml to Hiera 5:

Hiera 3

---
:backends:
  - yaml

:yaml:
  :datadir: /etc/puppetlabs/code/hiera

:merge_behavior: deeper

:hierarchy:
  - "fqdn/%{::fqdn}"
  

Hiera 5

---
version: 5

hierarchy:
  - name: "yaml data"
    path: "fqdn/%{::fqdn}.yaml"

defaults:
  datadir: /etc/puppetlabs/code/hiera
  data_hash: yaml_data

When I perform puppet agent -t there are some lookup issues like

Server Error: Function lookup() did not find a value for the name 'profiles' on node

Lookup-output regarding Hiera 3: puppet lookup --explain foo

Warning: /etc/puppetlabs/puppet/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   (file: /etc/puppetlabs/puppet/hiera.yaml)
Warning: Undefined variable '::hypervisor'; 
   (file & line not available)
Warning: Undefined variable '::profile'; 
   (file & line not available)
Warning: Undefined variable '::hoster'; 
   (file & line not available)
Warning: /etc/puppetlabs/code/hiera/environment/production.yaml: file does not contain a valid yaml hash
Warning: /etc/puppetlabs/code/hiera/osfamily/Debian.yaml: file does not contain a valid yaml hash
Warning: /etc/puppetlabs/code/hiera/virtual/true.yaml: file does not contain a valid yaml hash
Searching for "lookup_options"
  Global Data Provider (hiera configuration version 3)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "yaml"
      Merge strategy hash
        Path "/etc/puppetlabs/code/hiera/fqdn/server.localdomain.lan.yaml"
          Original path: "fqdn/%{::fqdn}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/environment/production.yaml"
          Original path: "environment/%{::environment}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/hypervisor/.yaml"
          Original path: "hypervisor/%{::hypervisor}"
          Path not found
        Path "/etc/puppetlabs/code/hiera/profile/.yaml"
          Original path: "profile/%{::profile}"
          Path not found
        Path "/etc/puppetlabs/code/hiera/role/foreman.yaml"
          Original path: "role/%{::role}"
          Path not found
        Path "/etc/puppetlabs/code/hiera/operatingsystem/Debian.yaml"
          Original path: "operatingsystem/%{::operatingsystem}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/osfamily/Debian.yaml"
          Original path: "osfamily/%{::osfamily}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/virtual/kvm.yaml"
          Original path: "virtual/%{::virtual}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/virtual/true.yaml"
          Original path: "virtual/%{::is_virtual}"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/hoster/.yaml"
          Original path: "hoster/%{::x_hoster}"
          Path not found
        Path "/etc/puppetlabs/code/hiera/customer/server.yaml"
          Original path: "customer/acme"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/hiera/server-global/shared.yaml"
          Original path: "server-global/shared"
          Found key: "lookup_options" value: {
            "sudo::configs" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_users" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_folders" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_sshkeys" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_groups" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "facter::facts_hash" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "logrotate::rules" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "filebeat::inputs" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "deployment_helpers::clean_old_builds" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "crontab_symlinks::entries" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "firewall_hiera::rules" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            }
          }
        Path "/etc/puppetlabs/code/hiera/common.yaml"
          Original path: "common"
          Found key: "lookup_options" value: {
            "sudo::configs" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_users" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_folders" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_sshkeys" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "basemod_groups" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "facter::facts_hash" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "logrotate::rules" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "filebeat::inputs" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "deployment_helpers::clean_old_builds" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "crontab_symlinks::entries" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "apt::sources" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "simple_file::files" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            },
            "firewall_hiera::rules" => {
              "merge" => {
                "strategy" => "deep",
                "merge_hash_arrays" => true
              }
            }
          }
        Merged result: {
          "sudo::configs" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "basemod_users" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "basemod_folders" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "basemod_sshkeys" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "basemod_groups" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "facter::facts_hash" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "logrotate::rules" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "filebeat::inputs" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "deployment_helpers::clean_old_builds" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "crontab_symlinks::entries" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "apt::sources" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "simple_file::files" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          },
          "firewall_hiera::rules" => {
            "merge" => {
              "strategy" => "deep",
              "merge_hash_arrays" => true
            }
          }
        }
Searching for "foo"
  Global Data Provider (hiera configuration version 3)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "yaml"
      Path "/etc/puppetlabs/code/hiera/fqdn/server.localdomain.lan.yaml"
        Original path: "fqdn/%{::fqdn}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/environment/production.yaml"
        Original path: "environment/%{::environment}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/hypervisor/.yaml"
        Original path: "hypervisor/%{::hypervisor}"
        Path not found
      Path "/etc/puppetlabs/code/hiera/profile/.yaml"
        Original path: "profile/%{::profile}"
        Path not found
      Path "/etc/puppetlabs/code/hiera/role/foreman.yaml"
        Original path: "role/%{::role}"
        Path not found
      Path "/etc/puppetlabs/code/hiera/operatingsystem/Debian.yaml"
        Original path: "operatingsystem/%{::operatingsystem}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/osfamily/Debian.yaml"
        Original path: "osfamily/%{::osfamily}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/virtual/kvm.yaml"
        Original path: "virtual/%{::virtual}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/virtual/true.yaml"
        Original path: "virtual/%{::is_virtual}"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/hoster/.yaml"
        Original path: "hoster/%{::hoster}"
        Path not found
      Path "/etc/puppetlabs/code/hiera/customer/server.yaml"
        Original path: "customer/acme"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/server-global/shared.yaml"
        Original path: "server-global/shared"
        No such key: "foo"
      Path "/etc/puppetlabs/code/hiera/common.yaml"
        Original path: "common"
        No such key: "foo"

Lookup-output regarding Hiera 5:

Searching for "lookup_options"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "yaml data"
      Path "/etc/puppetlabs/code/hiera/fqdn/server.localdomain.lan.yaml"
        Original path: "fqdn/%{::fqdn}.yaml"
        No such key: "lookup_options"
Searching for "foo"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "yaml data"
      Path "/etc/puppetlabs/code/hiera/fqdn/server.localdomain.lan.yaml"
        Original path: "fqdn/%{::fqdn}.yaml"
        No such key: "foo"
Function lookup() did not find a value for the name 'foo'

So the output with Hiera 3 differs from the output with using Hiera 5. How can I accomplish that I get the same results with using Hiera 5?

Upvotes: 0

Views: 63

Answers (0)

Related Questions