Issue #16266 has been updated by eric sorenson.

Status changed from Unreviewed to Rejected

Yes, this is an underlying ruby problem, nothing special that puppet is doing.
----------------------------------------
Bug #16266: Hash iteration order in a template not consistent
https://projects.puppetlabs.com/issues/16266#change-70815

Author: Mathieu Parent
Status: Rejected
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.

Reply via email to