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

Resource defaults aren't completely evaluated by the compiler

    XMLWordPrintable

Details

    • Puppet Developer Experience
    • 4
    • PDE 2017-05-03, PDE 2017-05-31
    • Bug Fix
    • Hide
      Puppet has since the beginning evaluated collections before applying default values defined via resource type defaults, thereby making it impossible to use such values when performing collection. This is now changed and an example like below now works as expected:
      {code}
      File { tag => 'sc_test' }
      File { '/tmp/test': ensure => present }
      File <<| tag == 'sc_test' |>>
      {code}

      This change will affect existing logic where it was assumed that default values were set via resource type defaults were *not* present at the time of collection.
      Show
      Puppet has since the beginning evaluated collections before applying default values defined via resource type defaults, thereby making it impossible to use such values when performing collection. This is now changed and an example like below now works as expected: {code} File { tag => 'sc_test' } File { '/tmp/test': ensure => present } File <<| tag == 'sc_test' |>> {code} This change will affect existing logic where it was assumed that default values were set via resource type defaults were *not* present at the time of collection.
    • Manual

    Description

      Resource defaults are merged in when finish is called on resources by the compiler which leads to the add_defaults method in parser/resource.rb:

          def add_defaults
            scope.lookupdefaults(self.type).each do |name, param|
              unless @parameters.include?(name)
                self.debug "Adding default for #{name}"
       
                @parameters[name] = param.dup
              end
            end
          end
      

      This method loops over each default and adds values to the @parameters hash if they are unset. No more, no less. The problem is that simply altering the @parameters hash isn't sufficient to trigger the full effect of a resource parameter---the value must be present in the hash when the resource is evaluated by the compiler.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chuck Charlie Sharpsteen
              Kurt Wall Kurt Wall
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support

                  Time Tracking

                    Estimated:
                    Original Estimate - 1 week
                    1w
                    Remaining:
                    Remaining Estimate - 1 week
                    1w
                    Logged:
                    Time Spent - Not Specified
                    Not Specified