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

Puppet evaluates classes declared with parameters before classes declared without parameters

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 3.7.2
    • None
    • 1
    • Platform 2014-10-15

    Description

      When evaluating classes from an external node classifier, Puppet evaluates the set of those declared without parameters prior to the set of those declared with class parameters. This is a problem because this ordering causes "Error: Duplicate declaration" more commonly. In addition, the behavior is in contradiction to the code comment of, "This means classes with an empty set of parameters won't conflict even if the class has already been included."

      The following manifest behavior as it maps to ENC behavior illustrates the bug:

      It is common to write something like the following Puppet manifest:

      node default {
        include one
        class { one: foo => baz }
      }
      

      Which produces the following error:

      Error: Duplicate declaration: Class[One] is already declared; cannot redeclare at /workspace/serious/src/puppet/foo.pp:7 on node mccune.local
      Error: Duplicate declaration: Class[One] is already declared; cannot redeclare at /workspace/serious/src/puppet/foo.pp:7 on node mccune.local
      

      However, changing the order of the class declarations avoids the error:

      node default {
        class { one: foo => baz }
        include one
      }
      

      With results:

      Notice: Compiled catalog for mccune.local in environment production in 27.78 seconds
      Notice: foo=baz
      Notice: /Stage[main]/One/Notify[foo=baz]/message: defined 'message' as 'foo=baz'
      Notice: Finished catalog run in 0.04 seconds
      

      As it relates to node classification, the following code is the equivalent of the first Puppet manifest, which produces errors. The expected behavior is to match that of the second manifest, which does not produce errors:

      https://github.com/puppetlabs/puppet/blob/27a55585c4aa3fca1c359baef087d711737fa48a/lib/puppet/parser/compiler.rb#L140-L162

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jeff Jeff McCune
              Kurt Wall Kurt Wall
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support