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

Interpolation behavior in hiera.yaml changed between Puppet version 4.9.3 and 4.9.4

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.9.4
    • Fix Version/s: PUP 4.10.0
    • Component/s: None
    • Labels:
    • Template:
    • Team:
      Puppet Developer Experience
    • Story Points:
      1
    • Sprint:
      PDE 2017-03-22, PDE 2017-04-05
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      This was a regression in 4.9.4 from 4.9.3 that in some very rare cases could cause a v5 hiera.yaml file to ignore certain hierarchy levels. This only happened for hierarchy levels that interpolated a top-scope variable whose value was set after the _first_ Hiera lookup. Even then, it only occurred if the variable was an array or hash, the hierarchy level accesses one of its members with key.subkey notation, _and_ the variable was referenced with the top-scope namespace (`::attributes.role`).

      This problem is now fixed. However, we strongly recommend against making your hierarchy self-configuring like this. You should only interpolate the `$facts`, `$trusted`, and `$server_facts` variables in your hierarchy.
      Show
      This was a regression in 4.9.4 from 4.9.3 that in some very rare cases could cause a v5 hiera.yaml file to ignore certain hierarchy levels. This only happened for hierarchy levels that interpolated a top-scope variable whose value was set after the _first_ Hiera lookup. Even then, it only occurred if the variable was an array or hash, the hierarchy level accesses one of its members with key.subkey notation, _and_ the variable was referenced with the top-scope namespace (`::attributes.role`). This problem is now fixed. However, we strongly recommend against making your hierarchy self-configuring like this. You should only interpolate the `$facts`, `$trusted`, and `$server_facts` variables in your hierarchy.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      covered by unit tests

      Description

      When using an array in hiera.yaml changes of global variables are ignored in puppet 4.9.4.
      Example environments/development/hiera.yaml:

      ---
      version: 5
       
      defaults:
        datadir: 'data'
        data_hash: yaml_data
       
      hierarchy:
        - name: "Global settings"
          path: "global.yaml"
        - name: "Role specific settings"
          paths:
            - "roles/%{::roles.0}.yaml"
      

      Example test.pp:

      $roles = lookup('roles')
      $data = lookup('data', Array[String], 'unique')
      notify{"data: ${data}":}
      

      Example environments/development/data/global.yaml:

      roles:
              - test1
       
      data:
              - "from global"
      

      Example environments/development/data/roles/test1.yaml:

      data:
              - 'from test1'
      

      When running "puppet apply --environment=development test.pp" this results in:

      Warning: Undefined variable '::roles'; 
         (file & line not available)
      Notice: Compiled catalog for hostname in environment development in 0.07 seconds
      Notice: data: [from global]
      Notice: /Stage[main]/Main/Notify[data: [from global]]/message: defined 'message' as 'data: [from global]'
      Notice: Applied catalog in 0.17 seconds
      
      

      When changing

      "roles/%{::roles.0}.yaml"
      

      to

      "roles/%{roles.0}.yaml"
      

      puppet apply returns:

      Warning: Undefined variable 'roles'; 
         (file & line not available)
      Notice: Compiled catalog for hostname in environment development in 0.07 seconds
      Notice: data: [from global, from test1]
      Notice: /Stage[main]/Main/Notify[data: [from global, from test1]]/message: defined 'message' as 'data: [from global, from test1]'
      Notice: Applied catalog in 0.17 seconds
      

      In Puppet 4.9.3 both versions return the same result. This bug is probably related to PUP-7303.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                linus.lotz Linus Lotz
              • Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support