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

EPP template can't explicitly access top scope variables if there's no node definition in the scope chain

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 3.8.2, PUP 4.2.0
    • Component/s: Language
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2015-06-10
    • Release Notes:
      Bug Fix

      Description

      If you try to explicitly access a top scope variable that is shadowed by a template parameter, Puppet will incorrectly use the parameter value instead unless there's a node scope present in the scope chain.

      Manifest:

      $testvar = "from top scope"
       
      node 'magpie.lan' {
        $testvar = "from node scope"
      }
       
      include epp_class
       
      class epp_class {
        $testvar = "from the local scope"
       
        notify { "mynotify":
          message => epp( 'epp_test/future_epp_scope_bug.epp', { testvar => "from the params" } ),
        }
      }
      

      Template:

      <%- |$testvar| -%>
      testvar is <%= $testvar %>.
      Top testvar is <%= $::testvar %>
      Local testvar is <%= $epp_class::testvar %>.
      

      Result:

      testvar is from the params.
      Top testvar is from the params
      Local testvar is from the local scope.
      

      If you move that include epp_class into the node definition, it will instead say "Top testvar is from top scope".

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                nick.fagerlund Nicholas Fagerlund
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: