Re: How to compare two haproxy.cfg files?

2015-03-09 Thread Jonathan Matthews
On 8 March 2015 at 18:46, Tom Limoncelli tlimonce...@stackexchange.com wrote:
 The first step is to put the sections in a fixed order: First general,
 the defaults, then each listen/frontend/backend sorted by name.  That
 works fine and has been a big help.

Not a huge amount of help with your task, but don't forget that
multiple default sections are valid, and take effect on the
non-defaults sections following them - but only up to the /next/
defaults section.

I.e. (IIRC!) with this:

  defaultsA
  backend #1
  listener #2
  frontend #3
  defaults B
  listener #4

A's settings affect #1, #2 and #3, and B's settings affect #4.

It would be different and quite possibly materially different if you
concatenated all the defaults together at the top, and only then
defined #1-#4.

HTH,
Jonathan



How to compare two haproxy.cfg files?

2015-03-08 Thread Tom Limoncelli
I'm converting from haproxy.cfg files generated by one system to ones
that are generated by a very different system.  As part of the
process, I want to compare the old and new haproxy.cfg files to make
sure they are equivalent.  diff isn't useful because the sections
are in different orders, and the subcommands within the sections are
not ordered the same.

I'd like to normalize the old and new files so that diff comparisons
are easier.  I am writing a program to do so. (I'll open source it
when it is done).

The first step is to put the sections in a fixed order: First general,
the defaults, then each listen/frontend/backend sorted by name.  That
works fine and has been a big help.

The next step is to sort the subcommands within a section.  This will
make the subsections easier to compare.  However I can not simply sort
them lexicographically, however ACLs and other subcommands are depend
on the order they are declared. My hunch is that if I keep the
following subcommands in the order they appear in the original file,
all the other subcommands can be sorted alphabetically and put at the
top of that section:

acl
capture
http-request
redirect
req*
rsp*
tcp-request
use-server
use_backend

Is this hunch correct?  Are there other subcommands that are order dependent?

Thanks!
Tom