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

puppet-5.5.0 breaks lookup_options when used post-loading dynamic items from hiera.yaml

    XMLWordPrintable

Details

    • Bug
    • Status: Accepted
    • Low
    • Resolution: Unresolved
    • PUP 5.5.1
    • None
    • Hiera & Lookup
    • Phoenix
    • Needs Assessment
    • Needs Assessment

    Description

      Puppet Version: 5.5.1

      We are using array-iteration in our hiera.yaml to implement some kind of roles-concept.

      For this we have nodes that can define an array of roles.

      Those roles will be added to the hiera hierarchy by using the mapped_paths. The %{roles} variable is defined in our site.pp by using the lookup() function.

      Prior to 5.5.1 we could could define lookup_options in roles dynamically loaded roles and define merge behavior or hashes defined in thoses roles. With 5.5.1 this does not seem to work anylonger. Values can still be looked up though. 

      Below is a minimal reproducible case:

      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../hiera.yaml
      ---
      version: 5
      defaults:
      hierarchy:
        - name: "node"
          path: node.yaml
        - name: "roles"
          mapped_paths:
            - roles
            - role
            - "%{role}.yaml"
        - name: "Other YAML hierarchy levels"
          paths:
            - "common.yaml"
            
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/node.yaml
      roles:
        - firstrole
        - secondrole
       
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/common.yaml
       
      myhash:
        key1: value1
        key2: value2
        
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/firstrole.yaml
      lookup_options:
        myhash:
          merge:
            strategy: deep
       
      myhash:
        role1: value1
        role2: value2
        
      role1: role1
       
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat ../data/secondrole.yaml
      myhash:
        role1: value1
        role3: value3
        
      role2: role2
       
       
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# cat site.pp
      $roles = lookup( 'roles', Array[String], 'unique', [], )
      notice("roles: $roles")
      $ret = lookup('myhash')
      notice("myhash: $ret")
       
      $role1 = lookup('role1')
      $role2 = lookup('role2')
      notice("role1 var: $role1")
      notice("role2 var: $role2")
       
       
      puppet-agent-5.4.0:
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# puppet apply site.pp
      Warning: Undefined variable 'roles'; \n   (file & line not available)
      Notice: Scope(Class[main]): roles: [firstrole, secondrole]
      Notice: Scope(Class[main]): myhash: {key1 => value1, key2 => value2, role1 => value1, role3 => value3, role2 => value2}
      Notice: Scope(Class[main]): role1 var: role1
      Notice: Scope(Class[main]): role2 var: role2
      Notice: Compiled catalog for c312a1b640ef in environment production in 0.03 seconds
      Notice: Applied catalog in 0.01 seconds
       
      puppet-agent-5.5.1
      root@c312a1b640ef:/etc/puppetlabs/code/environments/production/manifests# puppet apply site.pp
      Warning: Undefined variable 'roles'; \n   (file & line not available)
      Notice: Scope(Class[main]): roles: [firstrole, secondrole]
      Notice: Scope(Class[main]): myhash: {role1 => value1, role2 => value2}
      Notice: Scope(Class[main]): role1 var: role1
      Notice: Scope(Class[main]): role2 var: role2
      Notice: Compiled catalog for c312a1b640ef in environment production in 0.02 seconds
      Notice: Applied catalog in 0.02 seconds
      
      

       

      When putting the lookup_options in the common.yaml, the deep merge will happen also.

       

      I couldn't find any related change in the Changelog for this change.

      Desired Behavior:

      I'd expect to lookup_options still to work.

      Actual Behavior:

       

      puppet lookup ignores the lookup_options defined in the roles.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sandres Stefan Andres
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Zendesk Support