Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11207

lookup() does not seem to work as expected

    XMLWordPrintable

Details

    • Improvement
    • Status: Needs Information
    • Normal
    • Resolution: Unresolved
    • PUP 6.9.0, PUP 7.8.0
    • None
    • Hiera & Lookup
    • Split
    • Needs Assessment

    Description

      Puppet Version: 7.X
      Puppet Server Version: 7.X
      OS Name/Version: Debian 10,Ubuntu 20.04

      With an environment hiera.yaml file that contains a hierarchy like:

      hierarchy:
      -name: per module config
        path: %{role}/%{module_name}.yaml
      

      Automatic class parameter lookup works as expected (ie. it is possible to define per module data in hiera). However the lookup() function when called with  parameters <MODULE NAME>::<SOMETHING> from any other module sets %{module_name} to the current module and not to <MODULE NAME>. The result is that lookup() does not find the parameter if the only place it is defined in is data/%{role}/%{module_name}.yaml

      Desired Behavior:

      lookup(<MODULE NAME>::<SOMETHING>) should always set %{module_name} to <MODULE NAME>.
       

      Proposed fix:

      lib/puppet/pops/lookup/invocation.rb | 2 +- modified lib/puppet/pops/lookup/invocation.rb
      @@ -72,7 +72,7 @@ class Invocation
       def lookup(key, module_name = nil)
       key = LookupKey.new(key) unless key.is_a?(LookupKey)
       @top_key = key
      - @module_name = module_name.nil? ? key.module_name : module_name
      + @module_name = key.module_name.nil? ? module_name : key.module_name
       save_current = self.class.current
       if save_current.equal?(self)
       yield
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rwouts remco wouts
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Zendesk Support