Skip to content

Commit

Permalink
Sort the Options Hash
Browse files Browse the repository at this point in the history
Sort the options hash by downcased key.  Any Match are forced to the end.  This works by sorting the options keys as an array so that it should work in ruby 1.8.7
  • Loading branch information
Chris Portman committed Apr 15, 2014
1 parent 86d9048 commit 89a42a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions templates/sshd_config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ Port <%= port %>
ListenAddress <%= listen %>
<%- end -%>
<%- scope.lookupvar('ssh::server::merged_options').sort_by{ |sk| (sk.to_s.downcase.include? "match") ? sk.to_s : '' }.each do |k, v| -%>
<%- options = scope.lookupvar('ssh::server::merged_options') -%>
<%- options.keys.sort_by{ |sk| (sk.to_s.downcase.include? "match") ? 'zzz' + sk.to_s : sk.to_s }.each do |k| -%>
<%- v = options[k] -%>
<%- if v.is_a?(Hash) -%>
<%= k %>
<%- v.sort.each do |key, value| -%>
<%- v.keys.sort.each do |key| -%>
<%- value = v[key] -%>
<%- if value.is_a?(Array) -%>
<%- value.each do |a| -%>
<%= key %> <%= a %>
Expand Down

0 comments on commit 89a42a4

Please sign in to comment.