Issue #16266 has been updated by Mathieu Parent.
Reading the doc more in depth, I see that: * in Ruby 1.8, "The order in which you traverse a hash by either key or value may seem arbitrary, and will generally not be in the insertion order." (http://www.ruby-doc.org/core-1.8.7/Hash.html) * in Ruby 1.9, "Hashes enumerate their values in the order that the corresponding keys were inserted." (http://www.ruby-doc.org/core-1.9.3/Hash.html) So, this is a Ruby 1.8-only problem. ---------------------------------------- Bug #16266: Hash iteration order in a template not consistent https://projects.puppetlabs.com/issues/16266#change-70599 Author: Mathieu Parent Status: Unreviewed Priority: Normal Assignee: Category: Target version: Affected Puppet version: Keywords: Branch: In a manifest for creating an Apache config file, I define a hash like this: $aliases = { '/foo/' => '/home/foo/www/', '/bar/' => '/home/bar/www/', '/baz/' => '/home/baz/www//' } Then, in a template, I have: <% aliases.each_pair do |key, val| -%> Alias <%= key %> <%= val %> <% end -%> The result is mostly what I expect, but every once in a while, the order in which the Aliases are generated from the 'each_pair' loop changes, resulting in a different file. The Ruby docs state that "hashes enumerate their values in the order that the corresponding keys were inserted.", but is that not true for Puppet hashes? Sorting the hash will allow consistent printing, but what if input order is preferred? NB: This has already be mentioned at https://groups.google.com/forum/?fromgroups=#!topic/puppet-users/8mjAVGh8rRI -- 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.
