As soon as you have more than a few frontend, backend and listen directives in your HAProxy config thing get crowded in that single monolithic file. There are few possible solutions to this “problem”, like this python solution, or maybe using multiple config files and specifying them with -f when starting haproxy (http://comments.gmane.org/gmane.comp.web.haproxy/5888).
While there is nothing wrong with above mentioned solutions I think there is a better aproach where script would check if new configuration is valid before restarting HAProxy. Script below assumes you have colordiff, and etckeeper installed and configured. If you don’t you should think about using etckeeper, it can save you from trouble when you need to revert some changes in /etc directory.
First create /etc/haproxy/conf.d/ and split your haproxy.cfg in multiple files prefixed with numbers in order in which you would like them to be in final config. IE. in 00-global.cfg put your global options, and in 99-global.cfg put everything you want at the end of final HAProxy config file. If you need to disable one site simple rename it into 11-site1.cfg.disable, and run this script: https://gist.github.com/jlazic/e65f5bda141ffaed5640.
Edit: I have been using this script for a month now and it works great. If only there would be a way to dump running HAProxy configuration, and diff that config with one on the disk.
This might work for dumping configs -> https://github.com/PearsonEducation/Thalassa-Conduit
I wanted to let you know that I made a French translation of your article which can be found here:
As I didn’t find your email address, I use this form to let you know.