Issue #5662 has been updated by Jesse Wolfe. Status changed from Ready For Testing to Available In Testing Branch Target version changed from Statler to 2.6.x
I'd be happier if the unit test changes were in the same commit as the code change, but I'm not going to quibble. Available in `2.6.next` as of commit:6260687ee00f409c4b718f7e6f244ae844dab7d3 ---------------------------------------- Bug #5662: Parsedfile provider does not work with composite keys https://projects.puppetlabs.com/issues/5662 Author: Stefan Schulte Status: Available In Testing Branch Priority: Normal Assignee: Stefan Schulte Category: provider Target version: 2.6.x Affected Puppet version: 2.6.0 Keywords: Branch: https://github.com/stschulte/puppet/tree/ticket/2.6.x/5662 When one uses the parsedfileprovider for a type with multiple key_attributes the propertyhash is not filled with all keyattributes. I found the bug while creating the following parsedfile provider: # This provider parses /etc/services. name and protocol are key_attributes record_line :parsed, :fields => %w{name number protocol port_aliases description}, :optional => %w{port_aliases description}, :match => /^(\S*)\s+(\d*)\/(\S*)\s*(.*?)?\s*(?:#\s*(.*))?$/, :post_parse => proc { |hash| # Remark: I can see that hash[:protocol] exists and is valid hash[:protocol] = hash[:protocol].intern if hash[:protocol] # [... some more ruby code that does not touch hash[:protocol] in any way ...] }, :to_line => proc { |hash| # :protocol is NOT set here thus raising an error [:name, :number, :protocol].each do |n| raise Puppet::Error, "#{n} is a required attribute for port but not included in #{hash.inspect}" unless hash[n] and hash[n] != :absent end # [... some more ruby code to build a /etc/service line ..] } Raised error: Could not evaluate: protocol is a required attribute for port but not included in {:on_disk=>true, :number=>"25", :target=>"/etc/services", ensure=>:present, :name=>"foo", :record_type=>:parsed If I understand the parsedfileprovider correctly this is causing the bug: * The create method in puppet/provider/parsedfile.rb is putting all validproperties in the property_hash hash * Keyattributes are parameters and thus are not landing in the hash so name and protocol are not stored in that hash * The flush method in `parsedfile.rb` has some special handling for name because it does a final `@property_hash[:name] ||= @resource.name` * The flush method does not treat other key_attributes in this special way so all other keyattributes are not present in the to_line hook, -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
