The puppetlabs-haproxy module has a minor annoyance where by the
"bind" statements are sorted lexicographically instead of by IP
address. (Full description here:
https://tickets.puppetlabs.com/browse/MODULES-1919)
My attempt to fix this bug was to change the ERB template:
diff --git a/templates/fragments/_bind.erb b/templates/fragments/_bind.erb
index e60983a..a04d021 100644
--- a/templates/fragments/_bind.erb
+++ b/templates/fragments/_bind.erb
@@ -1,6 +1,6 @@
<% require 'ipaddr' -%>
<%- if @bind -%>
-<%- @bind.sort.map do |address_port, bind_params| -%>
+<%- @bind.sort_by { |address_port, bind_params|
address_port.split('.').map{ |octet| octet.to_i} }.map do
|address_port, bind_params| -%>
bind <%= address_port -%> <%= Array(bind_params).join(" ") %>
<%- end -%>
<%- else -%>
This works. However, the results are slightly different on old
versions of Ruby. If you look at the TravisCI output, you'll see
slightly different results for Ruby 1.8.7. It looks like something
changed in Ruby 1.9.
https://travis-ci.org/puppetlabs/puppetlabs-haproxy/builds/57502529
I don't have a lot of deep Ruby knowledge. Can anyone suggest either a
way to fix the code or the test?
Thanks!
Tom
--
Email:
t...@whatexit.org Work: tlimo...@StackOverflow.com
Skype: YesThatTom
Blog:
http://EverythingSysadmin.com