Gabriel Filion
2014-Mar-11 16:27 UTC
[Puppet Users] stdlib: result from join_keys_to_values() is unstable
Hi there, Say I have a hash like {a=>'1',b=>'2'} and I'd like to get a string that looks like "a=1,b=2". I tried using a combination of join_keys_to_values() and join() and the result looked correct, but was unstable. That unstability is because hashes are not always "sorted" the same way. An unstable string means that the config file in which I use it gets modified for no reason from time to time and this triggers an unnecessary service refresh. I'm currently using an inline template to achieve what I want, since with ruby I can use h.sort.map to always get results in the same order from a hash "h". Thing is, stdlib's sort() function only accepts strings or arrays. Is there a way to get a "stable" string with current means? Otherwise, would it be an acceptable idea to add support for hashes in sort() ? -- Gabriel Filion